mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 14:51:44 +01:00
temporarily removed iOS NFC implementation (commented out)
This commit is contained in:
parent
d865103558
commit
5f44194f0f
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
@ -26,7 +27,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchLink>Full</MtouchLink>
|
||||
<MtouchLink>SdkOnly</MtouchLink>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
</PropertyGroup>
|
||||
@ -78,8 +79,8 @@
|
||||
<None Include="Info.plist" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="CNFC\Card.cs" />
|
||||
<Compile Include="CNFC\Reader.cs" />
|
||||
<Compile Include="CNFC\Hardware.cs" />
|
||||
<Compile Include="CNFC\Reader.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
|
||||
@ -177,8 +178,10 @@
|
||||
<PackageReference Include="Prism.DryIoc.Forms">
|
||||
<Version>8.0.0.1909</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1687" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
|
||||
<PackageReference Include="Xamarin.Forms">
|
||||
<Version>4.7.0.1351</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
@ -1,67 +1,67 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using CoreNFC;
|
||||
using Foundation;
|
||||
using NFC;
|
||||
using NFC.ISO7816_4;
|
||||
//using System;
|
||||
//using System.Threading;
|
||||
//using CoreNFC;
|
||||
//using Foundation;
|
||||
//using NFC;
|
||||
//using NFC.ISO7816_4;
|
||||
|
||||
namespace Borepin.iOS.CNFC
|
||||
{
|
||||
public class Card : ICard
|
||||
{
|
||||
private NFCTagReaderSession _session;
|
||||
private INFCMiFareTag _tag;
|
||||
//namespace Borepin.iOS.CNFC
|
||||
//{
|
||||
// public class Card : ICard
|
||||
// {
|
||||
// private NFCTagReaderSession _session;
|
||||
// private INFCMiFareTag _tag;
|
||||
|
||||
public Card(NFCTagReaderSession session, INFCMiFareTag tag)
|
||||
{
|
||||
_session = session;
|
||||
_tag = tag;
|
||||
}
|
||||
// public Card(NFCTagReaderSession session, INFCMiFareTag tag)
|
||||
// {
|
||||
// _session = session;
|
||||
// _tag = tag;
|
||||
// }
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
var counter = new CountdownEvent(1);
|
||||
NSError err = null;
|
||||
// public void Connect()
|
||||
// {
|
||||
// var counter = new CountdownEvent(1);
|
||||
// NSError err = null;
|
||||
|
||||
_session.ConnectTo(_tag, (error) =>
|
||||
{
|
||||
err = error;
|
||||
counter.Signal();
|
||||
});
|
||||
// _session.ConnectTo(_tag, (error) =>
|
||||
// {
|
||||
// err = error;
|
||||
// counter.Signal();
|
||||
// });
|
||||
|
||||
counter.Wait();
|
||||
// counter.Wait();
|
||||
|
||||
if (err != null)
|
||||
{
|
||||
throw new Exception(err.LocalizedDescription);
|
||||
}
|
||||
}
|
||||
// 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 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;
|
||||
// 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();
|
||||
});
|
||||
// _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();
|
||||
// counter.Wait();
|
||||
|
||||
return new APDUResponse(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return new APDUResponse(buf);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,24 +1,24 @@
|
||||
using System;
|
||||
using CoreNFC;
|
||||
using NFC;
|
||||
//using System;
|
||||
//using CoreNFC;
|
||||
//using NFC;
|
||||
|
||||
namespace Borepin.iOS.CNFC
|
||||
{
|
||||
public class Hardware : IHardware
|
||||
{
|
||||
public bool IsAvailable()
|
||||
{
|
||||
return NFCReaderSession.ReadingAvailable;
|
||||
}
|
||||
//namespace Borepin.iOS.CNFC
|
||||
//{
|
||||
// public class Hardware : IHardware
|
||||
// {
|
||||
// public bool IsAvailable()
|
||||
// {
|
||||
// return NFCReaderSession.ReadingAvailable;
|
||||
// }
|
||||
|
||||
public String[] GetReaders()
|
||||
{
|
||||
return new String[] { "main" };
|
||||
}
|
||||
// public String[] GetReaders()
|
||||
// {
|
||||
// return new String[] { "main" };
|
||||
// }
|
||||
|
||||
public IReader OpenReader(String readerID)
|
||||
{
|
||||
return new Reader();
|
||||
}
|
||||
}
|
||||
}
|
||||
// public IReader OpenReader(String readerID)
|
||||
// {
|
||||
// return new Reader();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,66 +1,66 @@
|
||||
using System;
|
||||
using CoreFoundation;
|
||||
using CoreNFC;
|
||||
using Foundation;
|
||||
using NFC;
|
||||
//using System;
|
||||
//using CoreFoundation;
|
||||
//using CoreNFC;
|
||||
//using Foundation;
|
||||
//using NFC;
|
||||
|
||||
namespace Borepin.iOS.CNFC
|
||||
{
|
||||
public class Reader : NFCTagReaderSessionDelegate, IReader
|
||||
{
|
||||
public event ReaderEventHandler CardDiscovered;
|
||||
public event ReaderEventHandler CardLost;
|
||||
//namespace Borepin.iOS.CNFC
|
||||
//{
|
||||
// public class Reader : NFCTagReaderSessionDelegate, IReader
|
||||
// {
|
||||
// public event ReaderEventHandler CardDiscovered;
|
||||
// public event ReaderEventHandler CardLost;
|
||||
|
||||
private NFCReaderSession _session = null;
|
||||
private DispatchQueue _queue;
|
||||
// private NFCReaderSession _session = null;
|
||||
// private DispatchQueue _queue;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_queue = new DispatchQueue("NFC Reader Queue", true);
|
||||
// public void Start()
|
||||
// {
|
||||
// _queue = new DispatchQueue("NFC Reader Queue", true);
|
||||
|
||||
// sessions cannot be reused
|
||||
_session = new NFCTagReaderSession(NFCPollingOption.Iso14443, this, _queue)
|
||||
{
|
||||
AlertMessage = "TODO",
|
||||
};
|
||||
// // sessions cannot be reused
|
||||
// _session = new NFCTagReaderSession(NFCPollingOption.Iso14443, this, _queue)
|
||||
// {
|
||||
// AlertMessage = "TODO",
|
||||
// };
|
||||
|
||||
if (_session == null)
|
||||
{
|
||||
Console.WriteLine("Oh no! The session is null!");
|
||||
}
|
||||
// if (_session == null)
|
||||
// {
|
||||
// Console.WriteLine("Oh no! The session is null!");
|
||||
// }
|
||||
|
||||
_session.BeginSession();
|
||||
}
|
||||
// _session.BeginSession();
|
||||
// }
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_session?.InvalidateSession();
|
||||
_session = null;
|
||||
}
|
||||
// public void Stop()
|
||||
// {
|
||||
// _session?.InvalidateSession();
|
||||
// _session = null;
|
||||
// }
|
||||
|
||||
public override void DidDetectTags(NFCTagReaderSession session, INFCTag[] tags)
|
||||
{
|
||||
Console.WriteLine("Did detect tags");
|
||||
// public override void DidDetectTags(NFCTagReaderSession session, INFCTag[] tags)
|
||||
// {
|
||||
// Console.WriteLine("Did detect tags");
|
||||
|
||||
Console.WriteLine(tags[0].Type);
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
// //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");
|
||||
}
|
||||
}
|
||||
}
|
||||
// public override void DidInvalidate(NFCTagReaderSession session, NSError error)
|
||||
// {
|
||||
// // TODO: decide what to do
|
||||
// Console.WriteLine("reader session invalidated");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
Loading…
x
Reference in New Issue
Block a user