Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MifareClassicInterface.cs
1using Android.Nfc;
2using Android.Nfc.Tech;
4
6{
12 public class MifareClassicInterface(Tag Tag, MifareClassic Technology)
13 : NfcInterface(Tag, Technology), IMifareClassicInterface
14 {
15 private readonly MifareClassic mifareClassic = Technology;
16
20 public async Task<byte[]> ReadAllData()
21 {
22 //MifareClassicType Type = this.mifareClassic.Type;
23 int BlockCount = this.mifareClassic.BlockCount;
24 //int SectorCount = this.mifareClassic.SectorCount;
25 int TotalBytes = BlockCount << 4;
26 byte[] Data = new byte[TotalBytes];
27 int BlockIndex = 0;
28
29 while (BlockIndex < BlockCount)
30 {
31 byte[]? Block = await this.mifareClassic.ReadBlockAsync(BlockIndex++);
32 if (Block is null || Block.Length != 16)
33 throw UnableToReadDataFromDevice();
34
35 Array.Copy(Block, 0, Data, BlockIndex << 4, 16);
36 }
37
38 return Data;
39 }
40 }
41}
Mifare Classic interface, for communication with an NFC Tag.