Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
IsoDepInterface.cs
1using Android.Nfc;
2using Android.Nfc.Tech;
5
7{
13 public class IsoDepInterface(Tag Tag, IsoDep Technology)
14 : NfcInterface(Tag, Technology), IIsoDepInterface
15 {
16 private readonly IsoDep isoDep = Technology;
17
21 public Task<byte[]> GetHighLayerResponse()
22 {
23 return Task.FromResult(this.isoDep.GetHiLayerResponse() ?? throw UnableToReadDataFromDevice());
24 }
25
29 public Task<byte[]> GetHistoricalBytes()
30 {
31 return Task.FromResult(this.isoDep.GetHistoricalBytes() ?? throw UnableToReadDataFromDevice());
32 }
33
38 public void SetTimeout(int Timeout)
39 {
40 this.isoDep.SetTimeout(Timeout);
41 }
42
49 public async Task<byte[]> ExecuteCommand(byte[] Command, ICommunicationLayer CommunicationLayer)
50 {
51 CommunicationLayer.TransmitBinary(false, Command);
52
53 byte[]? Response = await this.isoDep.TransceiveAsync(Command);
54
55 if (Response is null)
56 {
57 CommunicationLayer.Error("No response returned.");
58 throw UnableToReadDataFromDevice();
59 }
60
61 CommunicationLayer.ReceiveBinary(false, Response);
62
63 return Response;
64 }
65 }
66}
Simple base class for classes implementing communication protocols.
void Error(string Error)
Called to inform the viewer of an error state.
void TransmitBinary(int Count)
Called when binary data has been transmitted.
void ReceiveBinary(int Count)
Called when binary data has been received.
ISO DEP interface, for communication with an NFC Tag.
void SetTimeout(int Timeout)
Sets communication timeout.
Interface for observable classes implementing communication protocols.