From c268638b3711cf36483cd970d5e3eedc56f34637 Mon Sep 17 00:00:00 2001
From: Carlson Lam <4546682+ksclam@users.noreply.github.com>
Date: Fri, 17 May 2019 11:53:16 +0800
Subject: [PATCH] Updates for 8K Block Read/Write
- UCODE DNA Demo
- Updates for Axzon UI
- 8K block read/write features
- 10 seconds interval when more the one block write (size large then 255)
---
.../BLE.Client.Droid/BLE.Client.Droid.csproj | 6 -
.../Properties/AndroidManifest.xml | 2 +-
.../Resources/values/style.xml | 1 +
.../BLE.Client/BLE.Client.iOS/Info.plist | 6 +-
.../BLE.Client/BLE.Client/BLE.Client.csproj | 20 +
.../BLE.Client/BleMvxApplication.cs | 24 +-
.../BLE.Client/BLE.Client/PageBlockWrite.xaml | 39 ++
.../BLE.Client/PageBlockWrite.xaml.cs | 122 +++++++
.../BLE.Client/BLE.Client/Pages/Page1.xaml | 10 -
.../BLE.Client/BLE.Client/Pages/Page1.xaml.cs | 20 -
.../BLE.Client/Pages/PageBlockWrite.xaml | 55 +++
.../BLE.Client/Pages/PageBlockWrite.xaml.cs | 65 ++++
.../BLE.Client/Pages/PageRFMicroSetting.xaml | 64 +++-
.../Pages/PageRFMicroSetting.xaml.cs | 163 ++++++++-
.../Pages/PageRFMicronInventory.xaml | 16 +-
.../Pages/PageRFMicronNickName.xaml.cs | 18 +
.../Pages/PageRFMicronNickname.xaml | 43 +++
.../Pages/PageSpecialFunctionsMenu.xaml | 1 +
.../BLE.Client/Pages/PageUCODEDNA.xaml | 148 ++++----
.../BLE.Client/Pages/PageUCODEDNA.xaml.cs | 117 ------
.../ViewModels/ViewModelBlockWrite.cs | 309 ++++++++++++++++
.../ViewModels/ViewModelMainMenu.cs | 1 +
.../ViewModels/ViewModelRFMicroInventory.cs | 343 +++++++++++++++++-
.../ViewModels/ViewModelRFMicroNickname.cs | 85 +++++
.../ViewModels/ViewModelRFMicroSetting .cs | 22 +-
.../ViewModelSpecialFunctionsMenu.cs | 6 +
.../ViewModels/ViewModelUCODEDNA.cs | 105 ++++--
.../RFIDReader/ClassRFID.Private.Write.cs | 95 +++++
.../CSLibrary/RFIDReader/ClassRFID.Private.cs | 10 +-
.../RFIDReader/ClassRFID.Public.Operation.cs | 4 +
CSLibrary/CSLibrary/RFIDReader/ClassRFID.cs | 54 ++-
.../Constants/CSLibrary.Constants.cs | 12 +
.../CSLibrary.Structures.TagWrite.cs | 87 +++--
.../Structures/CSLibrary.Structures.cs | Bin 313662 -> 314070 bytes
34 files changed, 1727 insertions(+), 346 deletions(-)
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml.cs
delete mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml
delete mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml.cs
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml.cs
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickName.xaml.cs
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickname.xaml
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelBlockWrite.cs
create mode 100755 CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroNickname.cs
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/BLE.Client.Droid.csproj b/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/BLE.Client.Droid.csproj
index 0636a66..048b347 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/BLE.Client.Droid.csproj
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/BLE.Client.Droid.csproj
@@ -44,9 +44,6 @@
Xamarin
btls
Xamarin.Android.Net.AndroidClientHandler
- false
- false
- false
pdbonly
@@ -61,9 +58,6 @@
1G
Xamarin
False
- false
- false
- false
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Properties/AndroidManifest.xml b/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Properties/AndroidManifest.xml
index 2d3e785..78425fa 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Properties/AndroidManifest.xml
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Resources/values/style.xml b/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Resources/values/style.xml
index 1691936..89c110d 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Resources/values/style.xml
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client.Droid/Resources/values/style.xml
@@ -8,5 +8,6 @@
- @color/accent
- @color/window_background
- true
+ - false
\ No newline at end of file
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client.iOS/Info.plist b/CS108 Demo/Source/BLE.Client/BLE.Client.iOS/Info.plist
index d82502c..176f762 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client.iOS/Info.plist
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client.iOS/Info.plist
@@ -25,7 +25,7 @@
UILaunchStoryboardName
LaunchScreen
CFBundleShortVersionString
- 2.0.15
+ 2.0.18
NSCalendarsUsageDescription
Only for testing, we don't need the data to do anything
UIApplicationExitsOnSuspend
@@ -54,6 +54,8 @@
CFBundleVersion
- 163
+ 174
+ NSLocationWhenInUseUsageDescription
+ 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
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/BLE.Client.csproj b/CS108 Demo/Source/BLE.Client/BLE.Client/BLE.Client.csproj
index 81e8f02..2ce69c3 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/BLE.Client.csproj
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/BLE.Client.csproj
@@ -50,9 +50,15 @@
PageBarcodeScan.xaml
+
+ PageBlockWrite.xaml
+
PageFilter.xaml
+
+ PageRFMicronNickname.xaml
+
PageRFMicroReadTemp.xaml
@@ -120,6 +126,7 @@
DeviceListPage.xaml
+
@@ -128,6 +135,7 @@
+
@@ -395,6 +403,18 @@
Designer
+
+
+ MSBuild:UpdateDesignTimeXaml
+ Designer
+
+
+
+
+ MSBuild:UpdateDesignTimeXaml
+ Designer
+
+
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/BleMvxApplication.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/BleMvxApplication.cs
index 3b01c29..d1f783d 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/BleMvxApplication.cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/BleMvxApplication.cs
@@ -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();
//RegisterAppStart();
+
}
//static async public void LoadConfig(string readerID)
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml
new file mode 100755
index 0000000..b6e5c6b
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml.cs
new file mode 100755
index 0000000..2ec6ecb
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/PageBlockWrite.xaml.cs
@@ -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);
+ }
+
+ }
+}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml
deleted file mode 100755
index 4fb1c84..0000000
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml.cs
deleted file mode 100755
index e165b67..0000000
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/Page1.xaml.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-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
-{
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class Page1 : ContentPage
- {
- public Page1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml
new file mode 100755
index 0000000..68d88f2
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml.cs
new file mode 100755
index 0000000..2a38e66
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageBlockWrite.xaml.cs
@@ -0,0 +1,65 @@
+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[] { "repeat 55AA", "repeat AA55", "repeat 0000", "repeat FFFF", "repeat 0001", "repeat 0002", "repeat 0004", "repeat 0008", "repeat 0010", "repeat 0020", "repeat 0040", "repeat 0080", "repeat 0100", "repeat 0200", "repeat 0400", "repeat 0800", "repeat 1000", "repeat 2000", "repeat 4000", "repeat 8000", "repeat FFFE", "repeat FFFD", "repeat FFFB", "repeat FFF7", "repeat FFEF", "repeat FFDF", "repeat FFBF", "repeat FF7F", "repeat FEFF", "repeat FDFF", "repeat FBFF", "repeat F7FF", "repeat EFFF", "repeat DFFF", "repeat BFFF", "repeat 7FFF" };
+ //UInt16[] _paddingValue = new UInt16[] { 0x55AA, 0xAA55, 0x0000, 0xFFFF, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0xFFFE, 0xFFFD, 0xFFFB, 0xFFF7, 0xFFEF, 0xFFDF, 0xFFBF, 0xFF7F, 0xFEFF, 0xFDFF, 0xFBFF, 0xF7FF, 0xEFFF, 0xDFFF, 0xBFFF, 0x7FFF };
+
+ public PageBlockWrite()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnAppearing()
+ {
+ base.OnAppearing();
+ }
+
+ 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;
+ }
+ }
+ }
+}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml
index e990cb8..826100a 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml
@@ -4,26 +4,56 @@
xmlns:pages="clr-namespace:BLE.Client.Pages;assembly=BLE.Client"
x:Class="BLE.Client.Pages.PageRFMicroSetting"
Title="Axzon Configuration">
+
+
+
+
-
-
+
+
+
+
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml.cs
index 03c2b72..83df995 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml.cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicroSetting.xaml.cs
@@ -11,53 +11,186 @@ namespace BLE.Client.Pages
{
public partial class PageRFMicroSetting
{
- string[] _sensorTypes = { "Sensor Code", "Temperature" };
- int [] _minOCRSSIs = { 0, 8 };
+ string[] _powerOptions = { "Low (16dBm)", "Mid (23dBm)", "High (30dBm)", "Auto (Trigger Cycle)", "Follow system Setting" };
+ string[] _indicatorsProfileOptions = { "Hot temperature", "Cold temperature", "Moisture detection" };
+ string[] _sensorTypeOptions = { "Sensor Code", "Temperature" };
+ string[] _sensorCodeUnitOptions = { "code", "%" };
+ string[] _temperatureUnitOptions = { "code", "ºF", "ºC" };
+ int[] _minOCRSSIs = { 0, 8 };
int [] _maxOCRSSIs = { 21, 18 };
+ string[] _thresholdComparisonOptions = { ">", "<" };
+ int[] _thresholdValueOptions = { 100, -1, 58 };
+ string [] _thresholdColorOptions = { "Red", "Blue"};
public PageRFMicroSetting()
{
InitializeComponent();
- SetParas(1);
+ buttonPower.Text = _powerOptions[2];
+ SetIndicatorsProfile(0);
}
protected override void OnAppearing()
{
+ buttonOK.RemoveBinding(Button.CommandProperty);
base.OnAppearing();
}
+ protected override void OnDisappearing()
+ {
+ buttonOK.RemoveBinding(Button.CommandProperty);
+ base.OnDisappearing();
+ }
+
public async void buttonTagTypeClicked(object sender, EventArgs e)
{
+ }
+ public async void buttonPowerClicked(object sender, EventArgs e)
+ {
+ var answer = await DisplayActionSheet("Power", "Cancel", null, _powerOptions);
+
+ if (answer != "Cancel")
+ {
+ buttonPower.Text = answer;
+ }
}
public async void buttonSensorTypeClicked(object sender, EventArgs e)
{
- var answer = await DisplayActionSheet("Sensor Type", "Cancel", null, _sensorTypes);
+ var answer = await DisplayActionSheet("Sensor Type", "Cancel", null, _sensorTypeOptions);
+
+ if (answer != "Cancel")
+ {
+ SetSensorType((uint)Array.IndexOf(_sensorTypeOptions, answer));
+ }
+ }
+
+ public async void buttonIndicatorsProfileClicked(object sender, EventArgs e)
+ {
+ var answer = await DisplayActionSheet("Indicators Profile", "Cancel", null, _indicatorsProfileOptions);
+
+ if (answer != "Cancel")
+ {
+ SetIndicatorsProfile((uint)Array.IndexOf(_indicatorsProfileOptions, answer));
+ }
+ }
+
+ public async void buttonSensorUnitClicked(object sender, EventArgs e)
+ {
+ string answer;
+
+ if (buttonSensorType.Text == _sensorTypeOptions[0])
+ answer = await DisplayActionSheet("Sensor Unit", "Cancel", null, _sensorCodeUnitOptions);
+ else
+ answer = await DisplayActionSheet("Sensor Unit", "Cancel", null, _temperatureUnitOptions);
+
+ if (answer != "Cancel")
+ {
+ buttonSensorUnit.Text = answer;
+ }
+ }
+
+ public async void buttonThresholdComparisonClicked(object sender, EventArgs e)
+ {
+ string answer = await DisplayActionSheet("Threshold Comparison", "Cancel", null, _thresholdComparisonOptions);
+
+ if (answer != "Cancel")
+ {
+ buttonThresholdComparison.Text = answer;
+ }
+ }
+
+ public async void buttonThresholdColorClicked(object sender, EventArgs e)
+ {
+ string answer = await DisplayActionSheet("Threshold Color", "Cancel", null, _thresholdColorOptions);
if (answer != "Cancel")
{
- for (uint index = 0; index < _sensorTypes.Length; index ++)
- {
- if (answer == _sensorTypes[index])
- {
- SetParas(index);
- break;
- }
- }
+ buttonThresholdColor.Text = answer;
}
}
- bool SetParas(uint index)
+ public async void ButtonOK_Clicked(object sender, EventArgs e)
{
- if (index >= _sensorTypes.Length)
+ BleMvxApplication._rfMicro_Power = Array.IndexOf(_powerOptions, buttonPower.Text);
+ BleMvxApplication._rfMicro_SensorType = Array.IndexOf(_sensorTypeOptions, buttonSensorType.Text);
+ switch (BleMvxApplication._rfMicro_SensorType)
+ {
+ case 0:
+ BleMvxApplication._rfMicro_SensorUnit = Array.IndexOf(_sensorCodeUnitOptions, buttonSensorUnit.Text);
+ if (BleMvxApplication._rfMicro_SensorUnit == 1)
+ BleMvxApplication._rfMicro_SensorUnit = 3;
+ break;
+ default:
+ BleMvxApplication._rfMicro_SensorUnit = Array.IndexOf(_temperatureUnitOptions, buttonSensorUnit.Text);
+ break;
+ }
+ BleMvxApplication._rfMicro_minOCRSSI = int.Parse(entryMinOCRSSI.Text);
+ BleMvxApplication._rfMicro_maxOCRSSI = int.Parse(entryMaxOCRSSI.Text);
+ BleMvxApplication._rfMicro_thresholdComparison = Array.IndexOf(_thresholdComparisonOptions, buttonThresholdComparison.Text);
+ BleMvxApplication._rfMicro_thresholdValue = int.Parse(entryThresholdValue.Text);
+ BleMvxApplication._rfMicro_thresholdColor = buttonThresholdColor.Text;
+
+ buttonOK.SetBinding(Button.CommandProperty, new Binding("OnOKButtonCommand"));
+ buttonOK.Command.Execute(1);
+ buttonOK.RemoveBinding(Button.CommandProperty);
+ }
+
+ bool SetIndicatorsProfile(uint index)
+ {
+ switch (index)
+ {
+ case 0:
+ buttonIndicatorsProfile.Text = _indicatorsProfileOptions[0];
+ SetSensorType(1);
+ buttonSensorUnit.Text = _temperatureUnitOptions[1];
+ buttonThresholdComparison.Text = _thresholdComparisonOptions[0];
+ entryThresholdValue.Text = _thresholdValueOptions[0].ToString();
+ buttonThresholdColor.Text = _thresholdColorOptions[0];
+ break;
+ case 1:
+ buttonIndicatorsProfile.Text = _indicatorsProfileOptions[1];
+ SetSensorType(1);
+ buttonSensorUnit.Text = _temperatureUnitOptions[2];
+ buttonThresholdComparison.Text = _thresholdComparisonOptions[1];
+ entryThresholdValue.Text = _thresholdValueOptions[1].ToString();
+ buttonThresholdColor.Text = _thresholdColorOptions[1];
+ break;
+ case 2:
+ buttonIndicatorsProfile.Text = _indicatorsProfileOptions[2];
+ SetSensorType(0);
+ buttonSensorUnit.Text = _sensorCodeUnitOptions[1];
+ buttonThresholdComparison.Text = _thresholdComparisonOptions[0];
+ entryThresholdValue.Text = _thresholdValueOptions[2].ToString();
+ buttonThresholdColor.Text = _thresholdColorOptions[1];
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+ bool SetSensorType(uint index)
+ {
+ if (index >= _sensorTypeOptions.Length)
return false;
- buttonSensorType.Text = _sensorTypes[index];
+ buttonSensorType.Text = _sensorTypeOptions[index];
entryMinOCRSSI.Text = _minOCRSSIs[index].ToString();
entryMaxOCRSSI.Text = _maxOCRSSIs[index].ToString();
+ switch (index)
+ {
+ case 0:
+ buttonSensorUnit.Text = _sensorCodeUnitOptions[0];
+ break;
+ default:
+ buttonSensorUnit.Text = _temperatureUnitOptions[2];
+ break;
+ }
+
return true;
}
}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronInventory.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronInventory.xaml
index b6079d6..f8f5eff 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronInventory.xaml
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronInventory.xaml
@@ -36,9 +36,9 @@
-
+
-
+
@@ -48,15 +48,19 @@
-
+
-
+
+
+
-
-
+
+
+
+
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickName.xaml.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickName.xaml.cs
new file mode 100755
index 0000000..ba77ab3
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickName.xaml.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+
+namespace BLE.Client.Pages
+{
+ public partial class PageRFMicroNickname
+ {
+ public PageRFMicroNickname()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickname.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickname.xaml
new file mode 100755
index 0000000..ab1f027
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageRFMicronNickname.xaml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageSpecialFunctionsMenu.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageSpecialFunctionsMenu.xaml
index bc6760a..2b0fd6d 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageSpecialFunctionsMenu.xaml
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageSpecialFunctionsMenu.xaml
@@ -12,6 +12,7 @@
+
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml
index 8c92ed9..8eb19bb 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml
@@ -5,83 +5,93 @@
x:Class="BLE.Client.Pages.PageUCODEDNA"
Title="Read Write">
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml.cs
index 3de5f6d..e4a3f30 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml.cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/Pages/PageUCODEDNA.xaml.cs
@@ -11,8 +11,6 @@ namespace BLE.Client.Pages
{
public partial class PageUCODEDNA
{
- int _EPCLength = 24;
-
public PageUCODEDNA()
{
InitializeComponent();
@@ -27,120 +25,5 @@ protected override void OnDisappearing()
{
base.OnDisappearing();
}
-
-#if nouse
- void InputFocused(object sender, EventArgs args)
- {
- double curY = ((Entry)sender).Y;
- double move;
-
- if (curY != 0)
- {
- move = -(curY - 97.5);
- }
- else
- {
- move = -174;
- }
-
- Content.LayoutTo(new Rectangle(0, move, Content.Bounds.Width, Content.Bounds.Height));
- }
-
- void InputACCPWDFocused(object sender, EventArgs args)
- {
- Content.LayoutTo(new Rectangle(0, -110, Content.Bounds.Width, Content.Bounds.Height));
- }
-
-
- void InputUnfocused(object sender, EventArgs args)
- {
- Content.LayoutTo(new Rectangle(0, 0, Content.Bounds.Width, Content.Bounds.Height));
- }
-
- int HexVal (string value, int offset = 1)
- {
- offset--;
- byte[] header = UnicodeEncoding.Unicode.GetBytes(value.Substring(offset, 1));
-
- if (header[0] >= 48 && header[0] <= 57)
- return (header[0] - 48);
- else if (header[0] >= 65 && header[0] <= 70)
- return (header[0] - 55);
- else if (header[0] >= 97 && header[0] <= 102)
- return (header[0] - 87);
- else
- return -1;
- }
-
- public async void onentryPCTextChanged(object sender, EventArgs e)
- {
- _EPCLength = 0;
-
- if (entryPC.Text.Length > 0)
- if (HexVal(entryPC.Text, entryPC.Text.Length) < 0)
- {
- entryPC.Text = entryPC.Text.Remove(entryPC.Text.Length - 1);
- return;
- }
-
- try
- {
- int epcWordLen;
-
- epcWordLen = HexVal(entryPC.Text.Substring(0, 1)) << 1;
- epcWordLen |= HexVal(entryPC.Text.Substring(1, 1)) >> 3;
-
- _EPCLength = epcWordLen * 4;
-
- labelEPCLength.Text = "EPC Length " + (epcWordLen * 16).ToString() + " bits";
- }
- catch (Exception ex)
- {
-
- }
- }
-
- public async void onentryPCUnfocused(object sender, EventArgs e)
- {
- if (entryPC.Text.Length == 0)
- entryPC.Text = "3000";
- if (entryPC.Text.Length > 4)
- entryPC.Text = entryPC.Text.Remove(4);
- else if (entryPC.Text.Length < 4)
- entryPC.Text += "0000".Remove(4-entryPC.Text.Length);
-
- onentryEPCTextChanged(sender, e);
- }
-
- public async void onentryEPCTextChanged(object sender, EventArgs e)
- {
- if (entryEPC.Text.Length > 0)
- if (HexVal(entryEPC.Text, entryEPC.Text.Length) < 0)
- {
- entryEPC.Text = entryEPC.Text.Remove(entryEPC.Text.Length - 1);
- return;
- }
-
- if (entryEPC.Text.Length < _EPCLength)
- entryEPC.TextColor = Color.Red;
- else
- {
- entryEPC.TextColor = Color.Black;
- if (entryEPC.Text.Length > _EPCLength)
- entryEPC.Text = entryEPC.Text.Remove(_EPCLength);
- }
- }
-
- public async void onentryEPCUnfocused(object sender, EventArgs e)
- {
- if (entryEPC.Text.Length != _EPCLength)
- {
- await DisplayAlert("EPC value invalid", "", null, "OK");
- entryEPC.Focus();
- }
- }
-
-#endif
-
}
}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelBlockWrite.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelBlockWrite.cs
new file mode 100755
index 0000000..250745b
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelBlockWrite.cs
@@ -0,0 +1,309 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Collections.Generic;
+using Acr.UserDialogs;
+using MvvmCross.Core.ViewModels;
+using MvvmCross.Platform;
+
+using System.Windows.Input;
+using Xamarin.Forms;
+
+
+using Plugin.BLE.Abstractions.Contracts;
+
+using Plugin.BLE.Abstractions;
+using Plugin.BLE.Abstractions.Extensions;
+
+namespace BLE.Client.ViewModels
+{
+ public class ViewModelBlockWrite : BaseViewModel
+ {
+ private readonly IUserDialogs _userDialogs;
+
+ public string editorSelectedEPCText { get; set; }
+ public string buttonBankText { get; set; }
+ public string buttonSizeText { get; set; }
+ public string buttonPaddingText { get; set; }
+ public string entryOffsetText { get; set; }
+ public string entryLengthText { get; set; }
+ public string buttonResultText { get; set; }
+
+ public ICommand buttonBlockWriteCommand { protected set; get; }
+ public ICommand buttonReadVerifyCommand { protected set; get; }
+ public ICommand buttonBlockWritewOffsetnCountCommand { protected set; get; }
+
+ DateTime _startingTime;
+ UInt16 _CurrentPadding;
+ UInt16 _RemainWriteSize;
+ UInt16 _RemainReadSize;
+
+ string[] _bankOptions = new string[] { "Bank3 (User Bank)", "Bank1 (EPC Bank)" };
+ string[] _sizeOptions = new string[] { "4K bit", "8K bit" };
+ string[] _paddingOptions = new string[] { "repeat 55AA", "repeat AA55", "repeat 0000", "repeat FFFF", "repeat 0001", "repeat 0002", "repeat 0004", "repeat 0008", "repeat 0010", "repeat 0020", "repeat 0040", "repeat 0080", "repeat 0100", "repeat 0200", "repeat 0400", "repeat 0800", "repeat 1000", "repeat 2000", "repeat 4000", "repeat 8000", "repeat FFFE", "repeat FFFD", "repeat FFFB", "repeat FFF7", "repeat FFEF", "repeat FFDF", "repeat FFBF", "repeat FF7F", "repeat FEFF", "repeat FDFF", "repeat FBFF", "repeat F7FF", "repeat EFFF", "repeat DFFF", "repeat BFFF", "repeat 7FFF" };
+ UInt16[] _paddingValue = new UInt16[] { 0x55AA, 0xAA55, 0x0000, 0xFFFF, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0xFFFE, 0xFFFD, 0xFFFB, 0xFFF7, 0xFFEF, 0xFFDF, 0xFFBF, 0xFF7F, 0xFEFF, 0xFDFF, 0xFBFF, 0xF7FF, 0xEFFF, 0xDFFF, 0xBFFF, 0x7FFF };
+
+ public ViewModelBlockWrite(IAdapter adapter, IUserDialogs userDialogs) : base(adapter)
+ {
+ _userDialogs = userDialogs;
+
+ buttonBlockWriteCommand = new Command(buttonBlockWriteClicked);
+ buttonReadVerifyCommand = new Command(buttonReadVerifyClicked);
+ buttonBlockWritewOffsetnCountCommand = new Command(buttonBlockWritewOffsetnCount);
+
+ editorSelectedEPCText = BleMvxApplication._SELECT_EPC;
+ buttonBankText = _bankOptions[0];
+ buttonSizeText = _sizeOptions[0];
+ buttonPaddingText = _paddingOptions[0];
+ entryOffsetText = "0";
+ entryLengthText = "255";
+
+ UpdatePage();
+ }
+
+ public override void Resume()
+ {
+ base.Resume();
+
+ BleMvxApplication._reader.rfid.OnAccessCompleted += new EventHandler(TagCompletedEvent);
+ }
+
+ public override void Suspend()
+ {
+ base.Suspend();
+
+ BleMvxApplication._reader.rfid.OnAccessCompleted -= new EventHandler(TagCompletedEvent);
+ }
+
+ protected override void InitFromBundle(IMvxBundle parameters)
+ {
+ base.InitFromBundle(parameters);
+ }
+
+ void UpdatePage()
+ {
+ InvokeOnMainThread(() =>
+ {
+ RaisePropertyChanged(() => editorSelectedEPCText);
+ RaisePropertyChanged(() => buttonBankText);
+ RaisePropertyChanged(() => buttonSizeText);
+ RaisePropertyChanged(() => buttonPaddingText);
+ RaisePropertyChanged(() => entryOffsetText);
+ RaisePropertyChanged(() => entryLengthText);
+ RaisePropertyChanged(() => buttonResultText);
+ });
+ }
+
+ async void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e)
+ {
+ InvokeOnMainThread(() =>
+ {
+ if (e.access == CSLibrary.Constants.TagAccess.READ)
+ {
+ switch (e.bank)
+ {
+ case CSLibrary.Constants.Bank.SPECIFIC:
+ if (!e.success)
+ {
+ buttonResultText = "Read Test Fail : Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString();
+ break;
+ }
+ else
+ {
+ int i;
+ UInt16[] data = BleMvxApplication._reader.rfid.Options.TagRead.pData.ToUshorts();
+
+ CSLibrary.Debug.WriteLine("Read Test : Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString() + " Result : " + (e.success ? "Success" : "Fail"));
+
+ CSLibrary.Debug.WriteLine("1");
+ if (data.Length != 32)
+ {
+ CSLibrary.Debug.WriteLine("Size error");
+ }
+ CSLibrary.Debug.WriteLine("2");
+
+ for (i = 0; i < data.Length; i++)
+ {
+ if (data[i] != _CurrentPadding)
+ {
+ buttonResultText = "Read OK, Verify Fail : Offset " + (BleMvxApplication._reader.rfid.Options.TagRead.offset + i).ToString();
+ break;
+ }
+ }
+
+ CSLibrary.Debug.WriteLine("3");
+ if (i == data.Length)
+ if (_RemainReadSize == 0)
+ {
+ buttonResultText = "Read/Verify Test success time " + (DateTime.Now - _startingTime).TotalSeconds.ToString("F2") + "s";
+ CSLibrary.Debug.WriteLine("Read Test Finish " + DateTime.Now + "/" + _startingTime);
+ CSLibrary.Debug.WriteLine("4");
+ }
+ else
+ {
+ BleMvxApplication._reader.rfid.Options.TagRead.offset += 32;
+ _RemainReadSize -= 32;
+
+ buttonResultText = "Reading... Offset " + BleMvxApplication._reader.rfid.Options.TagRead.offset.ToString();
+ BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_READ);
+ CSLibrary.Debug.WriteLine("5");
+ }
+ }
+ break;
+ }
+ }
+ CSLibrary.Debug.WriteLine("6");
+
+ if (e.access == CSLibrary.Constants.TagAccess.WRITE)
+ {
+ switch (e.bank)
+ {
+ case CSLibrary.Constants.Bank.SPECIFIC: // Block write bank
+ if (!e.success)
+ {
+ buttonResultText = "Block Write Test Fail : Offset " + BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset.ToString() + " Length " + BleMvxApplication._reader.rfid.Options.TagBlockWrite.count.ToString();
+ break;
+ }
+ else
+ {
+ if (_RemainWriteSize == 0)
+ {
+ buttonResultText = "Write Test success time " + (DateTime.Now - _startingTime).TotalSeconds.ToString("F2") + "s";
+ CSLibrary.Debug.WriteLine("Write Test Finish" + DateTime.Now + "/" + _startingTime);
+ }
+ else
+ {
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset += BleMvxApplication._reader.rfid.Options.TagBlockWrite.count;
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.count = _RemainWriteSize;
+
+ TurnBlockWriteSize();
+ FullPadding();
+ BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_BLOCK_WRITE);
+ }
+ }
+ break;
+ }
+ }
+ UpdatePage();
+ });
+ }
+
+ void SelectTag()
+ {
+ BleMvxApplication._reader.rfid.Options.TagSelected.epcMask = new CSLibrary.Structures.S_MASK(/*m_record.pc.ToString() + */editorSelectedEPCText);
+
+ 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);
+ }
+
+ async void buttonBlockWriteClicked()
+ {
+ UpdatePage();
+ UInt16 dataWordSize = (Array.IndexOf(_sizeOptions, buttonSizeText) == 0 ? (UInt16)256 : (UInt16)512);
+
+ BlockWrite(0, dataWordSize);
+ }
+
+ async void buttonReadVerifyClicked()
+ {
+ UpdatePage();
+ int paddingType = Array.IndexOf(_paddingOptions, buttonPaddingText);
+
+ _RemainReadSize = (UInt16)(((Array.IndexOf(_sizeOptions, buttonSizeText)) == 1) ? 512 : 256);
+ _CurrentPadding = _paddingValue[paddingType];
+
+ SelectTag();
+
+ switch (Array.IndexOf(_bankOptions, buttonBankText))
+ {
+ case 0:
+ BleMvxApplication._reader.rfid.Options.TagRead.bank = CSLibrary.Constants.MemoryBank.USER;
+ break;
+
+ default:
+ BleMvxApplication._reader.rfid.Options.TagRead.bank = CSLibrary.Constants.MemoryBank.BANK1;
+ break;
+ }
+ BleMvxApplication._reader.rfid.Options.TagRead.accessPassword = 0;
+ BleMvxApplication._reader.rfid.Options.TagRead.offset = 0; // 0
+ BleMvxApplication._reader.rfid.Options.TagRead.count = 32; // max 32 word
+ _RemainReadSize -= 32;
+
+ buttonResultText = buttonSizeText + " Reading...";
+ UpdatePage();
+ _startingTime = DateTime.Now;
+ BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_READ);
+ }
+
+ async void buttonBlockWritewOffsetnCount()
+ {
+ UpdatePage();
+ BlockWrite(UInt16.Parse(entryOffsetText), UInt16.Parse(entryLengthText));
+ }
+
+ void BlockWrite(UInt16 offset, UInt16 count)
+ {
+ _CurrentPadding = _paddingValue[Array.IndexOf(_paddingOptions, buttonPaddingText)];
+
+ SelectTag();
+
+ switch (Array.IndexOf(_bankOptions, buttonBankText))
+ {
+ case 0:
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.bank = CSLibrary.Constants.MemoryBank.USER;
+ break;
+
+ default:
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.bank = CSLibrary.Constants.MemoryBank.BANK1;
+ break;
+ }
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.flags = CSLibrary.Constants.SelectFlags.SELECT;
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.accessPassword = 0;
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset = offset;
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.count = count;
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.retryCount = 31;
+
+ TurnBlockWriteSize();
+ FullPadding();
+
+ CSLibrary.Debug.WriteLine("Block Write Test Start");
+ buttonResultText = "Block Writing...";
+ UpdatePage();
+ _startingTime = DateTime.Now;
+ BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_BLOCK_WRITE);
+ }
+
+ void TurnBlockWriteSize()
+ {
+ _RemainWriteSize = 0;
+
+ if (BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset < 256)
+ { // first 4k bank
+ int lastPostition = BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset + BleMvxApplication._reader.rfid.Options.TagBlockWrite.count;
+
+ if (lastPostition > 256)
+ {
+ _RemainWriteSize += (UInt16)(BleMvxApplication._reader.rfid.Options.TagBlockWrite.count - (256 - BleMvxApplication._reader.rfid.Options.TagBlockWrite.offset));
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.count -= _RemainWriteSize;
+ }
+ }
+
+ if (BleMvxApplication._reader.rfid.Options.TagBlockWrite.count > 255)
+ {
+ _RemainWriteSize += (UInt16)(BleMvxApplication._reader.rfid.Options.TagBlockWrite.count - 255);
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.count = 255;
+ }
+ }
+
+ void FullPadding()
+ {
+ UInt16[] data = new UInt16[BleMvxApplication._reader.rfid.Options.TagBlockWrite.count];
+
+ for (int i = 0; i < BleMvxApplication._reader.rfid.Options.TagBlockWrite.count; i++)
+ data[i] = _CurrentPadding;
+
+ BleMvxApplication._reader.rfid.Options.TagBlockWrite.data = data;
+ }
+ }
+}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelMainMenu.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelMainMenu.cs
index 1d9fa66..206e053 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelMainMenu.cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelMainMenu.cs
@@ -413,6 +413,7 @@ void OnConnectButtonClicked()
// for Geiger and Read/Write
BleMvxApplication._SELECT_EPC = "";
+ //BleMvxApplication._SELECT_EPC = "E280115020001144766E1800"; // for testing
BleMvxApplication._SELECT_PC = 3000;
// for PreFilter
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroInventory.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroInventory.cs
index a98ff9e..38322bc 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroInventory.cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroInventory.cs
@@ -16,16 +16,24 @@
using Prism.Mvvm;
+using Plugin.Share;
+using Plugin.Share.Abstractions;
namespace BLE.Client.ViewModels
{
public class ViewModelRFMicroInventory : BaseViewModel
- {
+ {
public class RFMicroTagInfoViewModel : BindableBase
{
private string _EPC;
public string EPC { get { return this._EPC; } set { this.SetProperty(ref this._EPC, value); } }
+ private string _NickName;
+ public string NickName { get { return this._NickName; } set { this.SetProperty(ref this._NickName, value); } }
+
+ private string _DisplayName;
+ public string DisplayName { get { return this._DisplayName; } set { this.SetProperty(ref this._DisplayName, value); } }
+
private uint _OCRSSI;
public uint OCRSSI { get { return this._OCRSSI; } set { this.SetProperty(ref this._OCRSSI, value); } }
@@ -42,6 +50,9 @@ public class RFMicroTagInfoViewModel : BindableBase
private string _RSSIColor;
public string RSSIColor { get { return this._RSSIColor; } set { this.SetProperty(ref this._RSSIColor, value); } }
+ private string _valueColor;
+ public string valueColor { get { return this._valueColor; } set { this.SetProperty(ref this._valueColor, value); } }
+
public RFMicroTagInfoViewModel()
{
}
@@ -49,15 +60,31 @@ public RFMicroTagInfoViewModel()
private readonly IUserDialogs _userDialogs;
- #region -------------- RFID inventory -----------------
+ #region -------------- RFID inventory -----------------
- public ICommand OnStartInventoryButtonCommand { protected set; get; }
+ public ICommand OnStartInventoryButtonCommand { protected set; get; }
public ICommand OnClearButtonCommand { protected set; get; }
+ public ICommand OnShareDataCommand { protected set; get; }
+
private ObservableCollection _TagInfoList = new ObservableCollection();
- public ObservableCollection TagInfoList { get { return _TagInfoList; } set { SetProperty(ref _TagInfoList, value); } }
+ public ObservableCollection TagInfoList { get { return _TagInfoList; } set { SetProperty(ref _TagInfoList, value); } }
- public string SensorValueTitle { get { return BleMvxApplication._sensorValueType == 0 ? "SC" : "Temp"; } }
+ public string SensorValueTitle { get {
+ switch (BleMvxApplication._rfMicro_SensorUnit)
+ {
+ case 0:
+ return "code";
+ case 1:
+ return "ºF";
+ case 2:
+ return "ºC";
+ case 3:
+ return "%";
+ }
+ return "Value";
+ }
+ }
private string _startInventoryButtonText = "Start Inventory";
public string startInventoryButtonText { get { return _startInventoryButtonText; } }
@@ -68,11 +95,11 @@ public RFMicroTagInfoViewModel()
public string tagPerSecondText { get { return _tagPerSecondText; } }
private string _numberOfTagsText = "0 tags";
public string numberOfTagsText { get { return _numberOfTagsText; } }
- private string _labelVoltage = "";
- public string labelVoltage { get { return _labelVoltage; } }
+ private string _labelVoltage = "";
+ public string labelVoltage { get { return _labelVoltage; } }
- private int _ListViewRowHeight = -1;
- public int ListViewRowHeight { get { return _ListViewRowHeight; } set { _ListViewRowHeight = value; } }
+ private int _ListViewRowHeight = -1;
+ public int ListViewRowHeight { get { return _ListViewRowHeight; } set { _ListViewRowHeight = value; } }
public bool _startInventory = true;
@@ -84,6 +111,9 @@ public RFMicroTagInfoViewModel()
private double _InventoryTime = 0;
public string InventoryTime { get { return ((uint)_InventoryTime).ToString() + "s"; } }
+ private string _currentPower;
+ public string currentPower { get { return _currentPower; } set { _currentPower = value; } }
+
private int _DefaultRowHight;
bool _cancelVoltageValue = false;
@@ -99,8 +129,11 @@ public ViewModelRFMicroInventory(IAdapter adapter, IUserDialogs userDialogs) : b
OnStartInventoryButtonCommand = new Command(StartInventoryClick);
OnClearButtonCommand = new Command(ClearClick);
+ OnShareDataCommand = new Command(ShareDataButtonClick);
RaisePropertyChanged(() => SensorValueTitle);
+
+ SetPowerString();
}
~ViewModelRFMicroInventory()
@@ -111,12 +144,12 @@ public override void Resume()
{
base.Resume();
- // RFID event handler
- BleMvxApplication._reader.rfid.OnAsyncCallback += new EventHandler(TagInventoryEvent);
+ // RFID event handler
+ BleMvxApplication._reader.rfid.OnAsyncCallback += new EventHandler(TagInventoryEvent);
// Key Button event handler
BleMvxApplication._reader.notification.OnKeyEvent += new EventHandler(HotKeys_OnKeyEvent);
- BleMvxApplication._reader.notification.OnVoltageEvent += new EventHandler(VoltageEvent);
+ BleMvxApplication._reader.notification.OnVoltageEvent += new EventHandler(VoltageEvent);
InventorySetting();
}
@@ -135,9 +168,9 @@ public override void Suspend()
// Key Button event handler
BleMvxApplication._reader.notification.OnKeyEvent -= new EventHandler(HotKeys_OnKeyEvent);
- BleMvxApplication._reader.notification.OnVoltageEvent -= new EventHandler(VoltageEvent);
+ BleMvxApplication._reader.notification.OnVoltageEvent -= new EventHandler(VoltageEvent);
- base.Suspend();
+ base.Suspend();
}
protected override void InitFromBundle(IMvxBundle parameters)
@@ -244,11 +277,48 @@ void InventorySetting()
BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_PRERANGING);
}
+ void SetPowerString ()
+ {
+ string[] _powerOptions = { "Low (16dBm)", "Mid (23dBm)", "High (30dBm)", "Auto ", "Follow System Setting" };
+
+ if (BleMvxApplication._rfMicro_Power == 3)
+ currentPower = "Auto " + _powerOptions[_powerRunning];
+ else
+ currentPower = _powerOptions[BleMvxApplication._rfMicro_Power];
+
+ RaisePropertyChanged(() => currentPower);
+ }
+
+ void SetPower(int index)
+ {
+ switch (index)
+ {
+ case 0:
+ BleMvxApplication._reader.rfid.SetPowerLevel(160);
+ break;
+ case 1:
+ BleMvxApplication._reader.rfid.SetPowerLevel(230);
+ break;
+ case 2:
+ BleMvxApplication._reader.rfid.SetPowerLevel(300);
+ break;
+ case 4:
+ BleMvxApplication._reader.rfid.SetPowerLevel((uint)BleMvxApplication._config.RFID_Power);
+ break;
+ }
+ }
+
+ int _powerRunning = 0;
void StartInventory()
{
if (_startInventory == false)
return;
+ if (BleMvxApplication._rfMicro_Power == 3)
+ SetPower(_powerRunning);
+ else
+ SetPower(BleMvxApplication._rfMicro_Power);
+
//TagInfoList.Clear();
StartTagCount();
@@ -269,7 +339,7 @@ void StartInventory()
RaisePropertyChanged(() => startInventoryButtonText);
}
- void StopInventory ()
+ void StopInventory()
{
_startInventory = true;
_startInventoryButtonText = "Start Inventory";
@@ -278,6 +348,12 @@ void StopInventory ()
BleMvxApplication._reader.rfid.StopOperation();
RaisePropertyChanged(() => startInventoryButtonText);
+ if (_powerRunning >= 2)
+ _powerRunning = 0;
+ else
+ _powerRunning++;
+ SetPowerString();
+
//BleMvxApplication._reader.rfid.CancelAllSelectCriteria(); // Confirm cancel all filter
}
@@ -400,11 +476,113 @@ private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
TagInfoList[cnt].OCRSSI = ocRSSI;
TagInfoList[cnt].RSSIColor = "Black";
- if (ocRSSI >= BleMvxApplication._minOCRSSI && ocRSSI <= BleMvxApplication._maxOCRSSI)
+ if (ocRSSI >= BleMvxApplication._rfMicro_minOCRSSI && ocRSSI <= BleMvxApplication._rfMicro_maxOCRSSI)
{
TagInfoList[cnt].GOODOCRSSI = ocRSSI.ToString();
- if (BleMvxApplication._sensorValueType == 0)
+ //BleMvxApplication._rfMicro_SensorType // 0 = Sensor code, 1 = Temp
+ //BleMvxApplication._rfMicro_SensorUnit //0=code, 1=f, 2=c, 3=%
+
+ switch (BleMvxApplication._rfMicro_SensorType)
+ {
+ case 0:
+ if (sensorCode >= 5 && sensorCode <= 490)
+ {
+ double SensorAvgValue;
+ TagInfoList[cnt].SucessCount++;
+
+ switch (BleMvxApplication._rfMicro_SensorUnit)
+ {
+ case 0: // code
+ {
+ TagInfoList[cnt]._sensorValueSum += sensorCode;
+ SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
+ TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
+ }
+ break;
+
+ default: // %
+ {
+ TagInfoList[cnt]._sensorValueSum += (double)sensorCode / 512 * 100;
+ SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
+ TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
+ }
+ break;
+ }
+
+ if (TagInfoList[cnt].SucessCount >= 3)
+ {
+ switch (BleMvxApplication._rfMicro_thresholdComparison)
+ {
+ case 0: // >
+ if (SensorAvgValue > BleMvxApplication._rfMicro_thresholdValue)
+ TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
+ else
+ TagInfoList[cnt].valueColor = "Green";
+ break;
+ default: // <
+ if (SensorAvgValue < BleMvxApplication._rfMicro_thresholdValue)
+ TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
+ else
+ TagInfoList[cnt].valueColor = "Green";
+ break;
+ }
+ }
+ }
+ break;
+
+ default:
+ if (temp >= 1300 && temp <= 3500)
+ {
+ double SensorAvgValue;
+ TagInfoList[cnt].SucessCount++;
+ UInt64 caldata = (UInt64)(((UInt64)info.Bank2Data[0] << 48) | ((UInt64)info.Bank2Data[1] << 32) | ((UInt64)info.Bank2Data[2] << 16) | ((UInt64)info.Bank2Data[3]));
+
+ switch (BleMvxApplication._rfMicro_SensorUnit)
+ {
+ case 0: // code
+ TagInfoList[cnt]._sensorValueSum += temp;
+ SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
+ TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
+ break;
+
+ case 1: // F
+ TagInfoList[cnt]._sensorValueSum += getTempF(temp, caldata);
+ SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
+ TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
+ break;
+
+ default: // C
+ TagInfoList[cnt]._sensorValueSum += getTempC(temp, caldata);
+ SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2);
+ TagInfoList[cnt].SensorAvgValue = SensorAvgValue.ToString();
+ break;
+ }
+
+ if (TagInfoList[cnt].SucessCount >= 3)
+ {
+ switch (BleMvxApplication._rfMicro_thresholdComparison)
+ {
+ case 0: // >
+ if (SensorAvgValue > BleMvxApplication._rfMicro_thresholdValue)
+ TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
+ else
+ TagInfoList[cnt].valueColor = "Green";
+ break;
+ default: // <
+ if (SensorAvgValue < BleMvxApplication._rfMicro_thresholdValue)
+ TagInfoList[cnt].valueColor = BleMvxApplication._rfMicro_thresholdColor;
+ else
+ TagInfoList[cnt].valueColor = "Green";
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ /*
+ if (BleMvxApplication._rfMicro_SensorUnit == 0)
{
if (sensorCode >= 5 && sensorCode <= 490)
{
@@ -423,6 +601,7 @@ private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
TagInfoList[cnt].SensorAvgValue = Math.Round(TagInfoList[cnt]._sensorValueSum / TagInfoList[cnt].SucessCount, 2).ToString();
}
}
+ */
}
else
{
@@ -439,18 +618,77 @@ private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
RFMicroTagInfoViewModel item = new RFMicroTagInfoViewModel();
item.EPC = info.epc.ToString();
+ item.NickName = GetNickName(item.EPC);
+ if (item.NickName != "")
+ item.DisplayName = item.NickName;
+ else
+ item.DisplayName = item.EPC;
item.OCRSSI = ocRSSI;
item.SucessCount = 0;
item._sensorValueSum = 0;
item.SensorAvgValue = "";
item.GOODOCRSSI = "";
item.RSSIColor = "Black";
+ item.valueColor = "Black";
- if (ocRSSI >= BleMvxApplication._minOCRSSI && ocRSSI <= BleMvxApplication._maxOCRSSI)
+ if (ocRSSI >= BleMvxApplication._rfMicro_minOCRSSI && ocRSSI <= BleMvxApplication._rfMicro_maxOCRSSI)
{
item.GOODOCRSSI = ocRSSI.ToString();
- if (BleMvxApplication._sensorValueType == 0)
+ //BleMvxApplication._rfMicro_SensorType // 0 = Sensor code, 1 = Temp
+ //BleMvxApplication._rfMicro_SensorUnit //0=code, 1=f, 2=c, 3=%
+
+ switch (BleMvxApplication._rfMicro_SensorType)
+ {
+ case 0:
+ if (sensorCode >= 5 && sensorCode <= 490)
+ {
+ item.SucessCount++;
+
+ switch (BleMvxApplication._rfMicro_SensorUnit)
+ {
+ case 0: // code
+ item._sensorValueSum = sensorCode;
+ item.SensorAvgValue = item._sensorValueSum.ToString();
+ break;
+
+ default: // %
+ item._sensorValueSum = (double)sensorCode / 512 * 100;
+ item.SensorAvgValue = item._sensorValueSum.ToString();
+ break;
+ }
+ }
+ break;
+
+ default:
+ if (temp >= 1300 && temp <= 3500)
+ {
+ item.SucessCount++;
+ UInt64 caldata = (UInt64)(((UInt64)info.Bank2Data[0] << 48) | ((UInt64)info.Bank2Data[1] << 32) | ((UInt64)info.Bank2Data[2] << 16) | ((UInt64)info.Bank2Data[3]));
+
+ switch (BleMvxApplication._rfMicro_SensorUnit)
+ {
+ case 0: // code
+ item._sensorValueSum = temp;
+ item.SensorAvgValue = item._sensorValueSum.ToString();
+ break;
+
+ case 1: // F
+ item._sensorValueSum = getTempF(temp, caldata);
+ item.SensorAvgValue = Math.Round(item._sensorValueSum, 2).ToString();
+ break;
+
+ default: // C
+ item._sensorValueSum = getTempC(temp, caldata);
+ item.SensorAvgValue = Math.Round(item._sensorValueSum, 2).ToString();
+ break;
+ }
+ }
+ break;
+ }
+
+ /*
+ if (BleMvxApplication._rfMicro_SensorUnit == 0)
{
if (sensorCode >= 5 && sensorCode <= 490)
{
@@ -468,7 +706,8 @@ private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
item._sensorValueSum = getTemperatue(info.Bank1Data[2], caldata);
item.SensorAvgValue = Math.Round(item._sensorValueSum, 2).ToString();
}
- }
+ }*/
+
}
else
{
@@ -485,6 +724,25 @@ private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
});
}
+ string GetNickName(string EPC)
+ {
+ for (int index = 0; index < ViewModelRFMicroNickname._TagNicknameList.Count; index++)
+ if (ViewModelRFMicroNickname._TagNicknameList[index].EPC == EPC)
+ return ViewModelRFMicroNickname._TagNicknameList[index].Nickname;
+
+ return "";
+ }
+
+ double getTempF(UInt16 temp, UInt64 CalCode)
+ {
+ return (getTemperatue(temp, CalCode) * 1.8 + 32.0);
+ }
+
+ double getTempC(UInt16 temp, UInt64 CalCode)
+ {
+ return getTemperatue(temp, CalCode);
+ }
+
double getTemperatue(UInt16 temp, UInt64 CalCode)
{
int crc = (int)(CalCode >> 48) & 0xffff;
@@ -535,6 +793,51 @@ void VoltageEvent(object sender, CSLibrary.Notification.VoltageEventArgs e)
RaisePropertyChanged(() => labelVoltage);
}
+ private void ShareDataButtonClick()
+ {
+ InvokeOnMainThread(() =>
+ {
+ string dataBase = "";
+
+ lock (TagInfoList)
+ {
+ for (int index = 0; index < TagInfoList.Count; index++)
+ {
+ dataBase += "\"" + TagInfoList[index].EPC + "\"," +
+ "\"" + TagInfoList[index].NickName + "\"," +
+ "\"" + ((BleMvxApplication._rfMicro_SensorType == 0) ? "Sensor code" : "Temperature") + "\"," +
+ TagInfoList[index].SensorAvgValue + "," +
+ "\"";
+ switch (BleMvxApplication._rfMicro_SensorUnit)
+ {
+ case 0:
+ dataBase += "code";
+ break;
+ case 1:
+ dataBase += "F";
+ break;
+ case 2:
+ dataBase += "C";
+ break;
+ case 3:
+ dataBase += "%";
+ break;
+ }
+ dataBase += "\"";
+ ;
+ }
+ }
+
+ var r = CrossShare.Current.Share(new Plugin.Share.Abstractions.ShareMessage
+ {
+ Text = dataBase,
+ Title = "Axzon tags list"
+ });
+
+ CSLibrary.Debug.WriteLine("BackupData : {0}", r.ToString());
+ });
+ }
+
#region Key_event
void HotKeys_OnKeyEvent(object sender, CSLibrary.Notification.HotKeyEventArgs e)
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroNickname.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroNickname.cs
new file mode 100755
index 0000000..eeba86d
--- /dev/null
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroNickname.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Collections.Generic;
+using Acr.UserDialogs;
+using MvvmCross.Core.ViewModels;
+using MvvmCross.Platform;
+
+using System.Windows.Input;
+using Xamarin.Forms;
+
+
+using Plugin.BLE.Abstractions.Contracts;
+
+using Plugin.BLE.Abstractions;
+using Plugin.BLE.Abstractions.Extensions;
+
+using Prism.Mvvm;
+
+using Plugin.Share;
+using Plugin.Share.Abstractions;
+
+namespace BLE.Client.ViewModels
+{
+ public class RFMicroTagNicknameViewModel : BindableBase
+ {
+ private string _EPC;
+ public string EPC { get { return this._EPC; } set { this.SetProperty(ref this._EPC, value); } }
+
+ private string _Nickname;
+ public string Nickname { get { return this._Nickname; } set { this.SetProperty(ref this._Nickname, value); } }
+ }
+
+ public class ViewModelRFMicroNickname : BaseViewModel
+ {
+
+ private readonly IUserDialogs _userDialogs;
+
+ #region -------------- RFID inventory -----------------
+
+ static public ObservableCollection _TagNicknameList = new ObservableCollection();
+ public ObservableCollection TagNicknameList { get { return _TagNicknameList; } set { SetProperty(ref _TagNicknameList, value); } }
+
+ #endregion
+
+ public ViewModelRFMicroNickname(IAdapter adapter, IUserDialogs userDialogs) : base(adapter)
+ {
+ _userDialogs = userDialogs;
+ }
+
+ ~ViewModelRFMicroNickname()
+ {
+ }
+
+ public override void Resume()
+ {
+ base.Resume();
+ }
+
+ public override void Suspend()
+ {
+ base.Suspend();
+ }
+
+ protected override void InitFromBundle(IMvxBundle parameters)
+ {
+ base.InitFromBundle(parameters);
+ }
+
+ async void ShowDialog(string Msg)
+ {
+ var config = new ProgressDialogConfig()
+ {
+ Title = Msg,
+ IsDeterministic = true,
+ MaskType = MaskType.Gradient,
+ };
+
+ using (var progress = _userDialogs.Progress(config))
+ {
+ progress.Show();
+ await System.Threading.Tasks.Task.Delay(1000);
+ }
+ }
+ }
+}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroSetting .cs b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroSetting .cs
index fc7ed56..5f0c8dc 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroSetting .cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelRFMicroSetting .cs
@@ -15,16 +15,21 @@ public class ViewModelRFMicroSetting : BaseViewModel
{
private readonly IUserDialogs _userDialogs;
+ public string buttonPowerText { get; set; }
+ public string buttonIndicatorsProfileText { get; set; }
public string buttonSensorTypeText { get; set; }
+ public string buttonSensorUnitText { get; set; }
public string entryMinOCRSSIText { get; set; }
public string entryMaxOCRSSIText { get; set; }
public ICommand OnOKButtonCommand { protected set; get; }
+ public ICommand OnNicknameButtonCommand { protected set; get; }
public ViewModelRFMicroSetting(IAdapter adapter, IUserDialogs userDialogs) : base(adapter)
{
_userDialogs = userDialogs;
OnOKButtonCommand = new Command(OnOKButtonClicked);
+ OnNicknameButtonCommand = new Command(OnNicknameButtonClicked);
}
public override void Resume()
@@ -42,17 +47,16 @@ protected override void InitFromBundle(IMvxBundle parameters)
base.InitFromBundle(parameters);
}
- void OnOKButtonClicked()
+ void OnNicknameButtonClicked(object ind)
{
- RaisePropertyChanged(() => buttonSensorTypeText);
- RaisePropertyChanged(() => entryMinOCRSSIText);
- RaisePropertyChanged(() => entryMaxOCRSSIText);
-
- BleMvxApplication._sensorValueType = buttonSensorTypeText == "Sensor Code" ? 0 : 1;
- BleMvxApplication._minOCRSSI = uint.Parse(entryMinOCRSSIText);
- BleMvxApplication._maxOCRSSI = uint.Parse(entryMaxOCRSSIText);
+ ShowViewModel(new MvxBundle());
+ }
- ShowViewModel(new MvxBundle());
+ void OnOKButtonClicked(object ind)
+ {
+ if (ind != null)
+ if ((int)ind == 1)
+ ShowViewModel(new MvxBundle());
}
}
}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelSpecialFunctionsMenu.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelSpecialFunctionsMenu.cs
index 8724608..ce8ab4b 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelSpecialFunctionsMenu.cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelSpecialFunctionsMenu.cs
@@ -21,6 +21,7 @@ public class ViewModelSpecialFunctionsMenu : BaseViewModel
public ICommand OnPeriodicReadButtonCommand { protected set; get; }
public ICommand OnUCODEDNAButtonCommand { protected set; get; }
public ICommand OnRFMicroButtonCommand { protected set; get; }
+ public ICommand OnBlockWriteButtonCommand { protected set; get; }
public ViewModelSpecialFunctionsMenu (IAdapter adapter, IUserDialogs userDialogs) : base(adapter)
@@ -32,6 +33,7 @@ public ViewModelSpecialFunctionsMenu (IAdapter adapter, IUserDialogs userDialogs
OnPeriodicReadButtonCommand = new Command(OnPeriodicReadButtonClicked);
OnUCODEDNAButtonCommand = new Command(OnUCODEDNAButtonClicked);
OnRFMicroButtonCommand = new Command(OnRFMicroButtonClicked);
+ OnBlockWriteButtonCommand = new Command(OnBlockWriteButtonClicked);
}
void OnMultiBankInventoryButtonClicked()
@@ -59,5 +61,9 @@ void OnRFMicroButtonClicked()
ShowViewModel(new MvxBundle());
}
+ void OnBlockWriteButtonClicked()
+ {
+ ShowViewModel(new MvxBundle());
+ }
}
}
diff --git a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelUCODEDNA.cs b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelUCODEDNA.cs
index 892d2e6..02525fc 100755
--- a/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelUCODEDNA.cs
+++ b/CS108 Demo/Source/BLE.Client/BLE.Client/ViewModels/ViewModelUCODEDNA.cs
@@ -31,15 +31,16 @@ public class ViewModelUCODEDNA : BaseViewModel
public string labelKey0Status { get; set; } = "";
public string labelKey1Status { get; set; } = "";
- public ICommand OnReadKeyButtonCommand { protected set; get; }
- public ICommand OnRandomKeyButtonCommand { protected set; get; }
- public ICommand OnWriteKeyButtonCommand { protected set; get; }
+ public ICommand OnReadKey0ButtonCommand { protected set; get; }
+ public ICommand OnReadKey1ButtonCommand { protected set; get; }
+ public ICommand OnWriteKey0ButtonCommand { protected set; get; }
+ public ICommand OnWriteKey1ButtonCommand { protected set; get; }
public ICommand OnHideButtonCommand { protected set; get; }
public ICommand OnUnhideButtonCommand { protected set; get; }
- public ICommand OnActivateKey0ButtonCommand { protected set; get; }
- public ICommand OnActivateKey1ButtonCommand { protected set; get; }
public ICommand OnAuthenticateTAM1ButtonCommand { protected set; get; }
public ICommand OnAuthenticateTAM2ButtonCommand { protected set; get; }
+ public ICommand OnActivateKey0ButtonCommand { protected set; get; }
+ public ICommand OnActivateKey1ButtonCommand { protected set; get; }
uint accessPwd;
@@ -60,9 +61,10 @@ public ViewModelUCODEDNA(IAdapter adapter, IUserDialogs userDialogs) : base(adap
{
_userDialogs = userDialogs;
- OnReadKeyButtonCommand = new Command(OnReadKeyButtonButtonClick);
- OnRandomKeyButtonCommand = new Command(OnRandomKeyButtonButtonClick);
- OnWriteKeyButtonCommand = new Command(OnWriteKeyButtonButtonClick);
+ OnReadKey0ButtonCommand = new Command(OnReadKey0ButtonButtonClick);
+ OnReadKey1ButtonCommand = new Command(OnReadKey1ButtonButtonClick);
+ OnWriteKey0ButtonCommand = new Command(OnWriteKey0ButtonButtonClick);
+ OnWriteKey1ButtonCommand = new Command(OnWriteKey1ButtonButtonClick);
OnHideButtonCommand = new Command(OnHideButtonButtonClick);
OnUnhideButtonCommand = new Command(OnUnhideButtonButtonClick);
OnActivateKey0ButtonCommand = new Command(OnActivateKey0ButtonButtonClick);
@@ -100,6 +102,8 @@ protected override void InitFromBundle(IMvxBundle parameters)
RaisePropertyChanged(() => entrySelectedKey1);
BleMvxApplication._reader.rfid.OnAccessCompleted += new EventHandler(TagCompletedEvent);
+
+ BleMvxApplication._reader.rfid.SetPowerLevel((uint)BleMvxApplication._config.RFID_Power);
}
void OnRandomKeyButtonButtonClick()
@@ -119,7 +123,7 @@ void OnRandomKeyButtonButtonClick()
RaisePropertyChanged(() => entrySelectedKey1);
}
- void OnReadKeyButtonButtonClick()
+ void OnReadKey0ButtonButtonClick()
{
accessPwd = Convert.ToUInt32(entrySelectedPWD, 16);
@@ -127,7 +131,15 @@ void OnReadKeyButtonButtonClick()
ReadKey0();
}
- void OnWriteKeyButtonButtonClick()
+ void OnReadKey1ButtonButtonClick()
+ {
+ accessPwd = Convert.ToUInt32(entrySelectedPWD, 16);
+
+ TagSelected();
+ ReadKey1();
+ }
+
+ void OnWriteKey0ButtonButtonClick()
{
accessPwd = Convert.ToUInt32(entrySelectedPWD, 16);
@@ -135,11 +147,19 @@ void OnWriteKeyButtonButtonClick()
WriteKey0();
}
+ void OnWriteKey1ButtonButtonClick()
+ {
+ accessPwd = Convert.ToUInt32(entrySelectedPWD, 16);
+
+ TagSelected();
+ WriteKey1();
+ }
+
void OnHideButtonButtonClick()
{
TagSelected();
- BleMvxApplication._reader.rfid.Options.TagUntraceable.EPCLength = 0; // NXP AN11778 only have EPCLength function
+ BleMvxApplication._reader.rfid.Options.TagUntraceable.EPCLength = 0; // NXP AN11778 only have EPCLength functional
/* for Gen2V2
BleMvxApplication._reader.rfid.Options.TagUntraceable.Range = CSLibrary.Structures.UNTRACEABLE_RANGE.Normal;
@@ -157,7 +177,7 @@ void OnUnhideButtonButtonClick()
{
TagSelected();
- BleMvxApplication._reader.rfid.Options.TagUntraceable.EPCLength = 6; // NXP AN11778 only have EPCLength function
+ BleMvxApplication._reader.rfid.Options.TagUntraceable.EPCLength = 6; // NXP AN11778 only have EPCLength functional
BleMvxApplication._reader.rfid.StartOperation(CSLibrary.Constants.Operation.TAG_UNTRACEABLE);
}
@@ -197,6 +217,9 @@ void OnActivateKey1ButtonButtonClick()
void OnAuthenticateTAM1ButtonButtonClick()
{
+ labelResponseStatus = "R";
+ RaisePropertyChanged(() => labelResponseStatus);
+
TagSelected();
BleMvxApplication._reader.rfid.Options.TagAuthenticate.SenRep = CSLibrary.Structures.SENREP.SEND;
@@ -208,6 +231,9 @@ void OnAuthenticateTAM1ButtonButtonClick()
void OnAuthenticateTAM2ButtonButtonClick()
{
+ labelResponseStatus = "R";
+ RaisePropertyChanged(() => labelResponseStatus);
+
TagSelected();
BleMvxApplication._reader.rfid.Options.TagAuthenticate.SenRep = CSLibrary.Structures.SENREP.SEND;
@@ -256,6 +282,13 @@ void ReadKey1 ()
void WriteKey0 ()
{
+ RaisePropertyChanged(() => entrySelectedKey0);
+ if (entrySelectedKey0.Length != 32)
+ {
+ _userDialogs.Alert("Key 0 Error, please input 128bit (32 hex)");
+ return;
+ }
+
_currentOperation = CURRENTOPERATION.WRITEKEY0;
labelKey0Status = "W";
@@ -271,6 +304,13 @@ void WriteKey0 ()
void WriteKey1 ()
{
+ RaisePropertyChanged(() => entrySelectedKey1);
+ if (entrySelectedKey1.Length != 32)
+ {
+ _userDialogs.Alert("Key 1 Error, please input 128bit (32 hex)");
+ return;
+ }
+
_currentOperation = CURRENTOPERATION.WRITEKEY1;
labelKey1Status = "W";
@@ -286,7 +326,32 @@ void WriteKey1 ()
void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArgs e)
{
- if (e.access == CSLibrary.Constants.TagAccess.READ)
+ if (e.access == CSLibrary.Constants.TagAccess.AUTHENTICATE)
+ {
+ if (e.success)
+ {
+ entryResponse = BleMvxApplication._reader.rfid.Options.TagAuthenticate.pData.ToString();
+ labelResponseStatus = "Ok";
+ RaisePropertyChanged(() => entryResponse);
+ }
+ else
+ {
+ labelResponseStatus = "E";
+ }
+ RaisePropertyChanged(() => labelResponseStatus);
+ }
+ else if (e.access == CSLibrary.Constants.TagAccess.UNTRACEABLE)
+ {
+ if (e.success)
+ {
+ _userDialogs.Alert("UNTRACEABLE command success!");
+ }
+ else
+ {
+ _userDialogs.Alert("UNTRACEABLE command fail!!!");
+ }
+ }
+ else if (e.access == CSLibrary.Constants.TagAccess.READ)
{
switch (e.bank)
{
@@ -326,14 +391,10 @@ void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArg
}
}
- if (_currentOperation == CURRENTOPERATION.READKEY0)
- ReadKey1();
-
break;
}
}
-
- if (e.access == CSLibrary.Constants.TagAccess.WRITE)
+ else if (e.access == CSLibrary.Constants.TagAccess.WRITE)
{
switch (e.bank)
{
@@ -376,11 +437,13 @@ void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArg
switch (_currentOperation)
{
case CURRENTOPERATION.WRITEKEY0:
+ case CURRENTOPERATION.ACTIVEKEY0:
labelKey0Status = "O";
RaisePropertyChanged(() => labelKey0Status);
break;
case CURRENTOPERATION.WRITEKEY1:
+ case CURRENTOPERATION.ACTIVEKEY1:
labelKey1Status = "O";
RaisePropertyChanged(() => labelKey1Status);
break;
@@ -391,23 +454,23 @@ void TagCompletedEvent(object sender, CSLibrary.Events.OnAccessCompletedEventArg
switch (_currentOperation)
{
case CURRENTOPERATION.WRITEKEY0:
+ case CURRENTOPERATION.ACTIVEKEY0:
labelKey0Status = "E";
RaisePropertyChanged(() => labelKey0Status);
break;
case CURRENTOPERATION.WRITEKEY1:
+ case CURRENTOPERATION.ACTIVEKEY1:
labelKey1Status = "E";
RaisePropertyChanged(() => labelKey1Status);
break;
}
}
- if (_currentOperation == CURRENTOPERATION.WRITEKEY0)
- WriteKey1();
-
break;
}
}
+
}
}
}
diff --git a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.Write.cs b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.Write.cs
index 36475ec..2d0d938 100755
--- a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.Write.cs
+++ b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.Write.cs
@@ -336,5 +336,100 @@ private void TagWriteUsrMemThreadProc()
FireStateChangedEvent(RFState.IDLE);
*/ }
}
+
+ private void BlockWriteThreadProc()
+ {
+ if (m_rdr_opt_parms.TagBlockWrite.retryCount > 31)
+ {
+ m_Result = Constants.Result.INVALID_PARAMETER;
+ return;
+ }
+
+ if (m_rdr_opt_parms.TagBlockWrite.count > 255)
+ {
+ m_Result = Constants.Result.INVALID_PARAMETER;
+ return;
+ }
+
+ try
+ {
+ FireStateChangedEvent(CSLibrary.Constants.RFState.BUSY);
+
+ m_Result = CSLibrary.Constants.Result.FAILURE;
+
+ MacWriteRegister(MACREGISTER.HST_TAGACC_ACCPWD, m_rdr_opt_parms.TagBlockWrite.accessPassword);
+ Start18K6CRequest(1, m_rdr_opt_parms.TagBlockWrite.flags);
+ MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG, 0x01 | (m_rdr_opt_parms.TagBlockWrite.retryCount << 1)); // Enable write verify and set retry count
+
+ // Set up the tag bank register (tells where to write the data)
+ MacWriteRegister(MACREGISTER.HST_TAGACC_BANK, (uint)m_rdr_opt_parms.TagBlockWrite.bank);
+
+ // Set the offset
+ MacWriteRegister(MACREGISTER.HST_TAGACC_PTR, m_rdr_opt_parms.TagBlockWrite.offset);
+
+ // Set up the access count register (i.e., number of words to write)
+ MacWriteRegister(MACREGISTER.HST_TAGACC_CNT, m_rdr_opt_parms.TagBlockWrite.count);
+
+ ushort DataSize = m_rdr_opt_parms.TagBlockWrite.count;
+ ushort WriteSize = DataSize;
+ // Write the values to the bank until either the bank is full or we run out of data
+ ushort registerAddress = (UInt16)MACREGISTER.HST_TAGWRDAT_0;
+ UInt32 registerBank = 0;
+ int pcnt = 0;
+
+ // Set up the HST_TAGWRDAT_N registers. Fill up a bank at a time.
+ for (registerBank = 0; DataSize > 0; registerBank++)
+ {
+ // Indicate which bank of tag write registers we are going to fill
+ MacWriteRegister(MACREGISTER.HST_TAGWRDAT_SEL, registerBank);
+
+ // Write the values to the bank until either the bank is full or we run out of data
+ registerAddress = (UInt16)MACREGISTER.HST_TAGWRDAT_0;
+
+ Debug.WriteLine("1. datasize:" + DataSize + " writesieze:" + WriteSize);
+ if (DataSize >= 32)
+ {
+ WriteSize = 32;
+ DataSize -= 32;
+ }
+ else
+ {
+ WriteSize = DataSize;
+ DataSize = 0;
+ }
+ Debug.WriteLine("2. datasize:" + DataSize + " writesieze:" + WriteSize);
+
+ while (WriteSize > 1)
+ {
+ // Set up the register and then write it to the MAC
+ UInt32 registerValue = (UInt32)((UInt32)m_rdr_opt_parms.TagBlockWrite.data[pcnt + 1] | (((UInt32)m_rdr_opt_parms.TagBlockWrite.data[pcnt]) << 16));
+
+ MacWriteRegister((MACREGISTER)(registerAddress), registerValue);
+
+ pcnt += 2;
+ registerAddress++;
+ WriteSize -= 2;
+ }
+
+ if (WriteSize == 1)
+ {
+ // Set up the register and then write it to the MAC
+ UInt32 registerValue = (uint)((UInt32)m_rdr_opt_parms.TagBlockWrite.data[pcnt] << 16);
+
+ MacWriteRegister((MACREGISTER)(registerAddress), registerValue);
+ }
+ }
+
+ _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.BLOCKWRITE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation);
+
+ m_Result = CSLibrary.Constants.Result.OK;
+ }
+ catch (System.Exception ex)
+ {
+ }
+ finally
+ {
+ }
+ }
}
}
diff --git a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.cs b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.cs
index c9cfdf1..b6f806f 100755
--- a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.cs
+++ b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Private.cs
@@ -869,9 +869,9 @@ private void TagAuthenticateThreadProc()
MacWriteRegister(MACREGISTER.AUTHENTICATE_MSG2, m_data[2]);
MacWriteRegister(MACREGISTER.AUTHENTICATE_MSG3, m_data[3]);
- Start18K6CRequest(0, CSLibrary.Constants.SelectFlags.SELECT);
+ Start18K6CRequest(1, CSLibrary.Constants.SelectFlags.SELECT);
- _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.AUTHENTICATE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE);
+ _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.AUTHENTICATE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation);
m_Result = Result.OK;
return;
}
@@ -881,7 +881,7 @@ private void TagReadBufferThreadProc()
MacWriteRegister(MACREGISTER.READBUFFER_PTR, m_rdr_opt_parms.TagReadBuffer.Offset);
MacWriteRegister(MACREGISTER.READBUFFER_LEN, (UInt32)(m_rdr_opt_parms.TagReadBuffer.Length & 0xfff));
- Start18K6CRequest(0, CSLibrary.Constants.SelectFlags.SELECT);
+ Start18K6CRequest(1, CSLibrary.Constants.SelectFlags.SELECT);
_deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.READBUFFER), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE);
m_Result = Result.OK;
@@ -907,10 +907,10 @@ private void TagUntraceableThreadProc()
MacWriteRegister( MACREGISTER.UNTRACEABLE_CFG, value);
- Start18K6CRequest(0, CSLibrary.Constants.SelectFlags.SELECT);
+ Start18K6CRequest(1, CSLibrary.Constants.SelectFlags.SELECT);
// Issue the untraceable command
- _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.UNTRACEABLE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE);
+ _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.UNTRACEABLE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation);
m_Result = Result.OK;
return;
}
diff --git a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Public.Operation.cs b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Public.Operation.cs
index fa1e17f..a207d4a 100755
--- a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Public.Operation.cs
+++ b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.Public.Operation.cs
@@ -138,6 +138,10 @@ public Result StartOperation(Operation opertion)
TagWriteUsrMemThreadProc();
break;
+ case Operation.TAG_BLOCK_WRITE:
+ BlockWriteThreadProc();
+ break;
+
case Operation.TAG_LOCK:
TagLockThreadProc();
break;
diff --git a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.cs b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.cs
index 80670b8..30ca54f 100755
--- a/CSLibrary/CSLibrary/RFIDReader/ClassRFID.cs
+++ b/CSLibrary/CSLibrary/RFIDReader/ClassRFID.cs
@@ -528,6 +528,18 @@ bool R2000Packet_TagAccess (byte[] recvData, int offset = 0)
case CSLibrary.Constants.Operation.TAG_READ_USER:
ArrayCopy(recvData, offset + 20, m_rdr_opt_parms.TagReadUser.m_pData, 0, m_rdr_opt_parms.TagReadUser.count * 2);
break;
+
+ case CSLibrary.Constants.Operation.TAG_AUTHENTICATE:
+ {
+ int pkt_len = recvData[5] << 8 | recvData[4];
+ int flags = recvData[1];
+ int len = ((pkt_len - 3) * 4) - ((flags >> 6) & 3);
+ byte[] response = new byte[len];
+ Array.Copy(recvData, offset + 20, response, 0, len);
+ m_rdr_opt_parms.TagAuthenticate.pData = new S_DATA(response);
+ //Array.Copy(recvData, offset + 20, m_rdr_opt_parms.TagAuthenticate.pData, 0, len);
+ }
+ break;
}
break;
@@ -577,10 +589,13 @@ bool R2000Packet_TagAccess (byte[] recvData, int offset = 0)
*/
break;
+ case 0xc7: // Block Write
+ break;
+
case 0x04: // EAS
break;
- case 0x00: // Untraceable?
+ case 0xe2: // Untraceable
break;
default:
@@ -863,6 +878,28 @@ internal CSLibrary.HighLevelInterface.BTWAITCOMMANDRESPONSETYPE DeviceRecvData(b
}
break;
+ case CSLibrary.Constants.Operation.TAG_AUTHENTICATE:
+ {
+ FireAccessCompletedEvent(
+ new OnAccessCompletedEventArgs(
+ (((currentCommandResponse | result) & HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.DATA1) != 0),
+ Bank.UNKNOWN,
+ TagAccess.AUTHENTICATE,
+ m_rdr_opt_parms.TagAuthenticate.pData));
+ }
+ break;
+
+ case CSLibrary.Constants.Operation.TAG_UNTRACEABLE:
+ {
+ FireAccessCompletedEvent(
+ new OnAccessCompletedEventArgs(
+ (((currentCommandResponse | result) & HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.DATA1) != 0),
+ Bank.UNKNOWN,
+ TagAccess.UNTRACEABLE,
+ m_rdr_opt_parms.TagAuthenticate.pData));
+ }
+ break;
+
case CSLibrary.Constants.Operation.TAG_WRITE:
{
FireAccessCompletedEvent(
@@ -929,6 +966,17 @@ internal CSLibrary.HighLevelInterface.BTWAITCOMMANDRESPONSETYPE DeviceRecvData(b
}
break;
+ case CSLibrary.Constants.Operation.TAG_BLOCK_WRITE:
+ {
+ FireAccessCompletedEvent(
+ new OnAccessCompletedEventArgs(
+ (((currentCommandResponse | result) & HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.DATA1) != 0),
+ Bank.SPECIFIC,
+ CSLibrary.Constants.TagAccess.WRITE,
+ m_rdr_opt_parms.TagReadUser.pData));
+ }
+ break;
+
case CSLibrary.Constants.Operation.TAG_LOCK:
{
CSLibrary.Debug.WriteLine("Tag lock end {0}", currentCommandResponse);
@@ -941,7 +989,7 @@ internal CSLibrary.HighLevelInterface.BTWAITCOMMANDRESPONSETYPE DeviceRecvData(b
null));
}
break;
-
+/*
case CSLibrary.Constants.Operation.TAG_UNTRACEABLE:
{
CSLibrary.Debug.WriteLine("Tag untraceable end {0}", currentCommandResponse);
@@ -954,7 +1002,7 @@ internal CSLibrary.HighLevelInterface.BTWAITCOMMANDRESPONSETYPE DeviceRecvData(b
null));
}
break;
-
+ */
}
}
diff --git a/CSLibrary/CSLibrary/RFIDReader/Constants/CSLibrary.Constants.cs b/CSLibrary/CSLibrary/RFIDReader/Constants/CSLibrary.Constants.cs
index 9d18de7..563b240 100755
--- a/CSLibrary/CSLibrary/RFIDReader/Constants/CSLibrary.Constants.cs
+++ b/CSLibrary/CSLibrary/RFIDReader/Constants/CSLibrary.Constants.cs
@@ -975,6 +975,10 @@ public enum Operation : int
///
TAG_WRITE_USER,
///
+ /// perform 18K6C block write to target tag
+ ///
+ TAG_BLOCK_WRITE,
+ ///
/// perform custom ranging on any tags
///
TAG_RANGING,
@@ -1289,6 +1293,14 @@ public enum TagAccess : byte
///
ERASE = 0xC6,
///
+ /// UCODE DNA Authenticate
+ ///
+ AUTHENTICATE = 0x01,
+ ///
+ /// UCODE DNA Untracable
+ ///
+ UNTRACEABLE = 0x02,
+ ///
/// Unknown
///
UNKNOWN = 0xff
diff --git a/CSLibrary/CSLibrary/RFIDReader/Structures/CSLibrary.Structures.TagWrite.cs b/CSLibrary/CSLibrary/RFIDReader/Structures/CSLibrary.Structures.TagWrite.cs
index f428a26..8922f52 100755
--- a/CSLibrary/CSLibrary/RFIDReader/Structures/CSLibrary.Structures.TagWrite.cs
+++ b/CSLibrary/CSLibrary/RFIDReader/Structures/CSLibrary.Structures.TagWrite.cs
@@ -244,41 +244,84 @@ public class TagWriteUserParms
}
-/*
- * ///
- /// Write User structures, configure this before write new user data
+ ///
+ /// The ISO 18000-6C tag-block write operation parameters
///
- [StructLayout(LayoutKind.Sequential)]
- public class TagWriteUserParms
+ public class TAG_BLOCK_WRITE_PARMS
{
///
- /// The access password for the tags. A value of zero indicates no
- /// access password.
+ /// The maximum number of times the write should be retried in the event
+ /// of write-verify failure(s). In the event of write-verify failure(s), the write
+ /// will be retried either for the specified number of retries or until the data
+ /// written is successfully verified. If the specified number of retries are
+ /// performed without successfully verifying the written data, the write
+ /// operation is considered to have failed and the tag-access operation-
+ /// response packet will indicate the error. This value must be between 0
+ /// and 31, inclusive.
+ /// If verify is non-zero, this parameter is ignored.
///
- public UInt32 accessPassword;
+ public uint retryCount = 31;
///
- /// Number of retrial will retry if write failure
+ /// Starting offset
///
- public UInt32 retryCount;
+ public ushort offset;
///
- /// The offset, in the memory bank, of the first 16-bit word to write.
+ /// Total number of words written to user memory
///
- public UInt16 offset;
+ public ushort count;
///
- /// The number of 16-bit words that will be written.
- ///
- public UInt16 count;
+ /// Write Buffer data to target tag
+ ///
+ public UInt16[] data = new UInt16[0];
///
- /// A array to the 16-bit values to write to the tag's memory bank.
+ /// Target Memory Bank
///
- public UInt16[] pData = new UInt16[0];
+ public MemoryBank bank = MemoryBank.UNKNOWN;
+ ///
+ /// Target Access Password
+ ///
+ public uint accessPassword;
///
- /// Constructor
+ /// Flag - Zero or combination of Select or Post-Match
///
- public TagWriteUserParms()
+ public SelectFlags flags = SelectFlags.SELECT;
+ }
+
+ /*
+ * ///
+ /// Write User structures, configure this before write new user data
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public class TagWriteUserParms
{
- // NOP
+ ///
+ /// The access password for the tags. A value of zero indicates no
+ /// access password.
+ ///
+ public UInt32 accessPassword;
+ ///
+ /// Number of retrial will retry if write failure
+ ///
+ public UInt32 retryCount;
+ ///
+ /// The offset, in the memory bank, of the first 16-bit word to write.
+ ///
+ public UInt16 offset;
+ ///
+ /// The number of 16-bit words that will be written.
+ ///
+ public UInt16 count;
+ ///
+ /// A array to the 16-bit values to write to the tag's memory bank.
+ ///
+ public UInt16[] pData = new UInt16[0];
+ ///
+ /// Constructor
+ ///
+ public TagWriteUserParms()
+ {
+ // NOP
+ }
}
- }
-*/
+ */
}
diff --git a/CSLibrary/CSLibrary/RFIDReader/Structures/CSLibrary.Structures.cs b/CSLibrary/CSLibrary/RFIDReader/Structures/CSLibrary.Structures.cs
index d1bb5cb88ba1c71b47ac7fba1c2cf0525b617cc4..f1c2b3b7eb34081b04fb26d92bcf05a3cf122129 100755
GIT binary patch
delta 69
zcmV-L0J{Iak`vaI6M%#PgaWh!R=bzbx&s!IfPM}GZ~#P;p%fLDu(tyemvF!Xp0@_P
b1GXZUj?4q>m*`CcR+oU(101)$-UEQ@;kg~a
delta 41
zcmV+^0M`H3l@q>_6M%#PgaWh!R=bx#!~;N*kZ@F1Z6(w?e!Fwj#Gw-~)o{X8I9!