From 2034c08d3377510bed3515cae71a1f67f8485491 Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Tue, 15 Sep 2020 10:47:46 +0200 Subject: [PATCH] Added: NFC csproj --- Borepin.sln | 28 ++++++++++++++++++- NFC/IReader.cs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ NFC/NFC.csproj | 7 +++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 NFC/IReader.cs create mode 100644 NFC/NFC.csproj diff --git a/Borepin.sln b/Borepin.sln index 011075a..dda3f6a 100644 --- a/Borepin.sln +++ b/Borepin.sln @@ -9,12 +9,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Borepin.Android", "Borepin\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Borepin.iOS", "Borepin\Borepin.iOS\Borepin.iOS.csproj", "{9985ED2B-0642-4DAC-98C3-F546196A1E36}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Borepin", "Borepin\Borepin\Borepin.csproj", "{F93856BD-0C8D-4469-A8DB-6E513002BFD7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Borepin", "Borepin\Borepin\Borepin.csproj", "{F93856BD-0C8D-4469-A8DB-6E513002BFD7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Borepin.GTK", "Borepin\Borepin.GTK\Borepin.GTK.csproj", "{61D956D2-5819-4736-BBD8-AD8208DE6A62}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Borepin.macOS", "Borepin\Borepin.macOS\Borepin.macOS.csproj", "{3EC23FE7-395E-4BBC-B56B-9455354BDA34}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NFC", "NFC\NFC.csproj", "{72DAC306-D4B2-4DBF-9C32-317203FD5D61}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -223,6 +225,30 @@ Global {3EC23FE7-395E-4BBC-B56B-9455354BDA34}.Release|x64.Build.0 = Release|Any CPU {3EC23FE7-395E-4BBC-B56B-9455354BDA34}.Release|x86.ActiveCfg = Release|Any CPU {3EC23FE7-395E-4BBC-B56B-9455354BDA34}.Release|x86.Build.0 = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|ARM.ActiveCfg = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|ARM.Build.0 = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|iPhone.Build.0 = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|x64.ActiveCfg = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|x64.Build.0 = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|x86.ActiveCfg = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Debug|x86.Build.0 = Debug|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|Any CPU.Build.0 = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|ARM.ActiveCfg = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|ARM.Build.0 = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|iPhone.ActiveCfg = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|iPhone.Build.0 = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|x64.ActiveCfg = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|x64.Build.0 = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|x86.ActiveCfg = Release|Any CPU + {72DAC306-D4B2-4DBF-9C32-317203FD5D61}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NFC/IReader.cs b/NFC/IReader.cs new file mode 100644 index 0000000..a0b05b1 --- /dev/null +++ b/NFC/IReader.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NFC +{ + /// + /// Abstract representation of the platform specific NFC Hardware. + /// + public interface IHardware + { + /// + /// Check if the device has nfc support. + /// + /// Returns true if the device supports NFC. + bool IsAvailable(); + + /// Returns all available readers. + String[] GetReader(); + + /// + /// Create a new reader instance from the specified id. + /// + /// Returns the spatform specific reader that corresponds to the id. + /// Invalid reader id. + IReader OpenReader(String readerID); + } + + /// + /// Abstraction of a platform-specifc reader that can communicate with NFC cards. + /// + public interface IReader + { + /// + /// Event that will be called when a new tag was discovered. + /// + event EventHandler CardDiscovered; + + /// + /// Event that will be called when a tag that is in use gets disconnected. + /// + event EventHandler CardLost; + + void start(); + + void stop(); + } + + public interface ICard + { + /// + /// Connect to Smartcard + /// + void Connect(); + + /// + /// Disconnect from Smartcard + /// + void Disconnect(); + + /// + /// Transmit APDU Command to Smartcard + /// + /// Application Protocol Data Unit Command - ISO 7816 + /// Application Protocol Data Unit Response - ISO 7816 + byte[] Transmit(byte[] apdu_cmd); + } + + public class ReaderUnavailableException : Exception { } + + public class CardUnavailableException : Exception { } + + public class APDUException : Exception { + public readonly byte ResponseCode; + } +} diff --git a/NFC/NFC.csproj b/NFC/NFC.csproj new file mode 100644 index 0000000..cb63190 --- /dev/null +++ b/NFC/NFC.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp3.1 + + +