More NFCService

This commit is contained in:
TheJoKlLa 2023-01-29 22:14:39 +01:00
parent 6e436b5c8c
commit 446dd850a3
3 changed files with 95 additions and 8 deletions

View File

@ -1,5 +1,7 @@
using Borepin.Service.NFC;
using NFC;
using NFC.Interfaces;
using NFC_PCSC;
using System;
using System.Collections.Generic;
using System.Linq;
@ -10,17 +12,69 @@ namespace Borepin.UWP.Services
{
public class NFCService : INFCService
{
public ICard GetCard()
#region Private Members
IHardware _Hardware;
IReader _Reader;
ICard _Card;
#endregion
#region Constructors
public NFCService(IHardware hardware = null)
{
if(hardware == null)
{
_Hardware = new Hardware_PCSC();
}
else
{
_Hardware = hardware;
}
}
#endregion
#region Members
public bool IsAvailable
{
get
{
return true;
}
}
public bool IsEnabled
{
get
{
return true;
}
}
public bool IsConnected
{
get
{
return _Reader != null && _Card != null;
}
}
#endregion
#region Methods
public IList<string> GetReaderIDs()
{
return new List<string>(_Hardware.GetReaders());
}
#endregion
public void Connect(string readerID)
{
throw new NotImplementedException();
}
public IHardware GetHardware()
public void Disconnect()
{
throw new NotImplementedException();
}
public IReader GetReader()
public APDUResponse Transmit(APDUCommand command)
{
throw new NotImplementedException();
}

View File

@ -1,4 +1,5 @@
using NFC.Interfaces;
using NFC;
using NFC.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
@ -10,8 +11,40 @@ namespace Borepin.Service.NFC
/// </summary>
public interface INFCService
{
IHardware GetHardware();
IReader GetReader();
ICard GetCard();
/// <summary>
/// Indicates if NFC Hardware is available
/// </summary>
bool IsAvailable { get; }
/// <summary>
/// Indicates if NFC Hardware is enabled
/// </summary>
bool IsEnabled { get; }
/// <summary>
/// Indicates if NFC Card is connected
/// </summary>
bool IsConnected { get; }
/// <summary>
/// Get a list of availible NFC ReaderIDs
/// </summary>
IList<string> GetReaderIDs();
/// <summary>
/// Connect with ReaderID to NFC Card
/// </summary>
/// <param name="readerID">ReaderID from GetReaderIDs</param>
void Connect(string readerID);
/// <summary>
/// Disconnects Reader from NFC Card
/// </summary>
void Disconnect();
/// <summary>
/// Transmit APDUCommand to Card if connected
/// </summary>
APDUResponse Transmit(APDUCommand command);
}
}

2
external/NFC vendored

@ -1 +1 @@
Subproject commit 4420dbf1b1e820d94d6adaa2b65a851ac582be8f
Subproject commit 327472bea06316a6d439b6b0224ffedd2c6f1bbc