Implemented NFC Card Reader Code from https://git.sterul.com/student-projects/dhbw...
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / nfcreader / MifareDESFire / DesfireManufacturingData.java
1 package de.dhbwloe.campusapp.nfcreader.MifareDESFire;
2
3 import java.io.ByteArrayInputStream;
4
5 import de.dhbwloe.campusapp.nfcreader.Hex;
6
7 /**
8  * Created by pk910 on 27.01.2016.
9  */
10 public class DesfireManufacturingData {
11     public final int hwVendorID;
12     public final int hwType;
13     public final int hwSubType;
14     public final int hwMajorVersion;
15     public final int hwMinorVersion;
16     public final int hwStorageSize;
17     public final int hwProtocol;
18
19     public final int swVendorID;
20     public final int swType;
21     public final int swSubType;
22     public final int swMajorVersion;
23     public final int swMinorVersion;
24     public final int swStorageSize;
25     public final int swProtocol;
26
27     public final int uid;
28     public final int batchNo;
29     public final int weekProd;
30     public final int yearProd;
31
32     public DesfireManufacturingData (byte[] data) {
33         ByteArrayInputStream stream = new ByteArrayInputStream(data);
34         hwVendorID     = stream.read();
35         hwType         = stream.read();
36         hwSubType      = stream.read();
37         hwMajorVersion = stream.read();
38         hwMinorVersion = stream.read();
39         hwStorageSize  = stream.read();
40         hwProtocol     = stream.read();
41
42         swVendorID     = stream.read();
43         swType         = stream.read();
44         swSubType      = stream.read();
45         swMajorVersion = stream.read();
46         swMinorVersion = stream.read();
47         swStorageSize  = stream.read();
48         swProtocol     = stream.read();
49
50         // FIXME: This has fewer digits than what's contained in EXTRA_ID, why?
51         byte[] buf = new byte[7];
52         stream.read(buf, 0, buf.length);
53         uid = Hex.byteArrayToInt(buf);
54
55         // FIXME: This is returning a negative number. Probably is unsigned.
56         buf = new byte[5];
57         stream.read(buf, 0, buf.length);
58         batchNo = Hex.byteArrayToInt(buf);
59
60         // FIXME: These numbers aren't making sense.
61         weekProd = stream.read();
62         yearProd = stream.read();
63     }
64
65 }