diff --git a/NFC_iOS/Card_iOS.cs b/NFC_iOS/Card_iOS.cs new file mode 100644 index 0000000..6eea52e --- /dev/null +++ b/NFC_iOS/Card_iOS.cs @@ -0,0 +1,66 @@ +//using System; +//using System.Threading; +//using NFC.Interfaces; +//using CoreNFC; +//using Foundation; + +//namespace NFC_iOS +//{ +// public class Card_iOS : ICard +// { +// private NFCTagReaderSession _session; +// private INFCMiFareTag _tag; + +// public Card_iOS(NFCTagReaderSession session, INFCMiFareTag tag) +// { +// _session = session; +// _tag = tag; +// } + +// public void Connect() +// { +// var counter = new CountdownEvent(1); +// NSError err = null; + +// _session.ConnectTo(_tag, (error) => +// { +// err = error; +// counter.Signal(); +// }); + +// counter.Wait(); + +// if (err != null) +// { +// throw new Exception(err.LocalizedDescription); +// } +// } + +// public void Disconnect() +// { +// // TODO: decide on which should be used +// //_session.RestartPolling(); +// _session.InvalidateSession("card disconnect"); +// } + +// public APDUResponse Transmit(APDUCommand cmd) +// { +// var counter = new CountdownEvent(1); +// byte[] buf = null; + +// _tag.SendMiFareIso7816Command(new NFCIso7816Apdu(NSData.FromArray(cmd.Data)), (response, sw1, sw2, NSError) => +// { +// // reassembly the original apdu message +// buf = new byte[response.Length + 2]; +// response.ToArray().CopyTo(buf, 0); +// buf[response.Length + 0] = sw1; +// buf[response.Length + 1] = sw2; +// counter.Signal(); +// }); + +// counter.Wait(); + +// return new APDUResponse(buf); +// } +// } +//} diff --git a/NFC_iOS/Hardware_iOS.cs b/NFC_iOS/Hardware_iOS.cs new file mode 100644 index 0000000..42ad5b8 --- /dev/null +++ b/NFC_iOS/Hardware_iOS.cs @@ -0,0 +1,24 @@ +//using System; +//using NFC.Interfaces; +//using CoreNFC; + +//namespace NFC_iOS +//{ +// public class Hardware_iOS : IHardware +// { +// public bool IsAvailable() +// { +// return NFCReaderSession.ReadingAvailable; +// } + +// public String[] GetReaders() +// { +// return new String[] { "main" }; +// } + +// public IReader OpenReader(String readerID) +// { +// return new Reader_iOS(); +// } +// } +//} diff --git a/NFC_iOS/NFC_iOS.csproj b/NFC_iOS/NFC_iOS.csproj index cb63190..a285d64 100644 --- a/NFC_iOS/NFC_iOS.csproj +++ b/NFC_iOS/NFC_iOS.csproj @@ -4,4 +4,12 @@ netcoreapp3.1 + + + + + + + + diff --git a/NFC_iOS/Reader_iOS.cs b/NFC_iOS/Reader_iOS.cs new file mode 100644 index 0000000..a65ba46 --- /dev/null +++ b/NFC_iOS/Reader_iOS.cs @@ -0,0 +1,65 @@ +//using NFC.Interfaces; +//using System; +//using CoreNFC; +//using Foundation; + +//namespace NFC_iOS +//{ +// public class Reader_iOS : NFCTagReaderSessionDelegate, IReader +// { +// public event ReaderEventHandler CardDiscovered; +// public event ReaderEventHandler CardLost; + +// private NFCReaderSession _session = null; +// private DispatchQueue _queue; + +// public void Start() +// { +// _queue = new DispatchQueue("NFC Reader Queue", true); + +// // sessions cannot be reused +// _session = new NFCTagReaderSession(NFCPollingOption.Iso14443, this, _queue) +// { +// AlertMessage = "TODO", +// }; + +// if (_session == null) +// { +// Console.WriteLine("Oh no! The session is null!"); +// } + +// _session.BeginSession(); +// } + +// public void Stop() +// { +// _session?.InvalidateSession(); +// _session = null; +// } + +// public override void DidDetectTags(NFCTagReaderSession session, INFCTag[] tags) +// { +// Console.WriteLine("Did detect tags"); + +// Console.WriteLine(tags[0].Type); + +// //INFCIso7816Tag tag = tags[0].GetNFCIso7816Tag(); +// INFCMiFareTag tag = tags[0].GetNFCMiFareTag(); +// if (tag != null) +// { +// Console.WriteLine("Card ist valid"); +// CardDiscovered?.Invoke(this, new Card(session, tag)); +// } +// else +// { +// Console.WriteLine("Card is not ISO7816"); +// } +// } + +// public override void DidInvalidate(NFCTagReaderSession session, NSError error) +// { +// // TODO: decide what to do +// Console.WriteLine("reader session invalidated"); +// } +// } +//}