Skip to content

Commit

Permalink
Version 1.4.8528
Browse files Browse the repository at this point in the history
Version 1.4.8528
-----------------------------------------------------------------
Backend related changes
- Feature: Added Support for MultiTag (Desfire + Legic Prime) recognition
  • Loading branch information
c3rebro committed May 8, 2023
1 parent 9ffff72 commit d02ac1a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
47 changes: 37 additions & 10 deletions RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ElatecNetProvider : ReaderDevice, IDisposable

private readonly TWN4ReaderDevice readerDevice;

private ChipModel card;
private ChipModel hfTag;
private bool _disposed;

#region Constructor
Expand Down Expand Up @@ -73,26 +73,38 @@ public override ERROR ReadChipPublic()
Instance.Connect();
}

card = readerDevice.GetSingleChip(true);
hfTag = readerDevice.GetSingleChip(true);

if (!string.IsNullOrWhiteSpace(card?.ChipIdentifier))
var lfTag = readerDevice.GetSingleChip(false);
var legicTag = readerDevice.GetSingleChip(true, true);

if (
!(
string.IsNullOrWhiteSpace(hfTag?.ChipIdentifier) &
string.IsNullOrWhiteSpace(lfTag?.ChipIdentifier) &
string.IsNullOrWhiteSpace(legicTag?.ChipIdentifier)
)
)
{
try
{
GenericChip = new GenericChipModel(card.ChipIdentifier,
(CARD_TYPE)card.CardType,

GenericChip = new GenericChipModel(hfTag.ChipIdentifier,
(CARD_TYPE)hfTag.CardType,
ByteConverter.GetStringFrom(readerDevice.SAK),
ByteConverter.GetStringFrom(readerDevice.ATS),
ByteConverter.GetStringFrom(readerDevice.L4VERSION)
);

var lfTag = readerDevice.GetSingleChip(false);

if (lfTag != null && lfTag?.CardType != ChipType.NOTAG)
{
GenericChip.Slave = new GenericChipModel(lfTag.ChipIdentifier, (RFiDGear.DataAccessLayer.CARD_TYPE)lfTag.CardType);
}
readerDevice.GetSingleChip(true);
else if(legicTag != null && legicTag?.CardType != ChipType.NOTAG)
{
GenericChip.Slave = new GenericChipModel(legicTag.ChipIdentifier, (RFiDGear.DataAccessLayer.CARD_TYPE)legicTag.CardType);
}
//readerDevice.GetSingleChip(true);

return ERROR.NoError;
}
Expand Down Expand Up @@ -148,8 +160,13 @@ public override ERROR Connect()
#region MifareClassic
public override ERROR WriteMifareClassicSingleBlock(int _blockNumber, string _aKey, string _bKey, byte[] buffer)
{
return WriteMifareClassicSingleSector(
CustomConverter.GetSectorNumberFromChipBasedDataBlockNumber(_blockNumber), _aKey, _bKey, buffer);
if (!readerDevice.MifareClassicLogin(_aKey, 0, (byte)CustomConverter.GetSectorNumberFromChipBasedDataBlockNumber(_blockNumber))) // No Access Allowed, try bKey
{
readerDevice.MifareClassicLogin(_bKey, 1, (byte)CustomConverter.GetSectorNumberFromChipBasedDataBlockNumber(_blockNumber));

} // Login

return readerDevice.MifareClassicWriteBlock(buffer, (byte)_blockNumber) == true ? ERROR.NoError : ERROR.AuthenticationError;
}

public override ERROR ReadMifareClassicSingleSector(int sectorNumber, string aKey, string bKey)
Expand Down Expand Up @@ -418,10 +435,20 @@ public override ERROR ChangeMifareDesfireApplicationKey(string _applicationMaste
1,
(byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget))))
{
if (readerDevice.DesfireAuthenticate(_applicationMasterKeyTarget, (byte)_keyNumberTarget, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)), 1))
{
readerDevice.DesfireChangeKeySettings((byte)keySettings, 0, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)));
}

return ERROR.NoError;
}
else
{
if (readerDevice.DesfireAuthenticate(_applicationMasterKeyTarget, (byte)_keyNumberTarget, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)), 1))
{
readerDevice.DesfireChangeKeySettings((byte)keySettings, 0, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)));
}

return ERROR.AuthenticationError;
}
}
Expand Down
2 changes: 1 addition & 1 deletion RFiDGear/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.3.*")]
[assembly: AssemblyVersion("1.4.*")]
[assembly: Guid("a34bc413-e349-4fd1-8b90-2eb95a333436")]
[assembly: NeutralResourcesLanguage("")]
10 changes: 2 additions & 8 deletions RFiDGear/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ public class MainWindowViewModel : ObservableObject

#region Events / Delegates

/// <summary>
/// will raise notifier to inform user about available updates
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void updateReady(object sender, EventArgs e);
#endregion

#region Constructors
Expand Down Expand Up @@ -1158,12 +1152,12 @@ private void OnNewWriteToChipOnceCommand()
treeViewParentNodes.First(x => x.IsSelected).IsSelected = false;
}

//only run if theres a card on the reader and its uid was previously added
//only run if theres a hfTag on the reader and its uid was previously added
if (
!string.IsNullOrWhiteSpace(GenericChip.UID) &&
treeViewParentNodes.Any(x => x.UID == GenericChip.UID))
{
//select current parentnode (card) on reader
//select current parentnode (hfTag) on reader
treeViewParentNodes.First(x => x.UID == GenericChip.UID).IsSelected = true;
treeViewParentNodes.First(x => x.IsSelected).IsBeingProgrammed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,7 @@ private void OnNewChangeMasterCardKeyCommand()
0,
SelectedDesfireMasterKeyEncryptionTypeCurrent,
DesfireMasterKeyTarget,
selectedDesfireAppKeyNumberTargetAsInt,
0,
0,
SelectedDesfireMasterKeyEncryptionTypeTarget, 0, 0, keySettings, keyVersionCurrentAsInt);

Expand Down

0 comments on commit d02ac1a

Please sign in to comment.