vthomw / ctm

design and build a continuous body temperature monitor (CTM)
Apache License 2.0
2 stars 3 forks source link

Read CGM via NFC #5

Open markus-oehme-pg40 opened 4 years ago

markus-oehme-pg40 commented 4 years ago

Aqcuire the data by reading the sensor via NFC.

The following Android code shows the core logic of this.

byte uid[8];
int numChunks = 43;
byte dataOut[344]
for (int i = 0; i < numChunks; i++) {
    byte[] cmd = new byte[]{
        (byte) 0x22, // flags: addressed (= UID field present) and high data rate mode
        (byte) 0x20, // command: read single block
        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, // placeholder for tag UID
        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, // placeholder for tag UID
        (byte) i,
    };
    System.arraycopy(uid, 0, cmd, 2, 8);
    byte[] answer = tag.transceive(cmd); // first byte of answer is return code
    System.arraycopy(answer, 1, dataOut, 8 * i, 8);
}