NFC Temperature Logger Commands

I am encoding an Android application. I have a temperature data logger SL13A, and I'm trying to read the temperature from the logger, but I really do not know how to do this.

Here is a technical description: http://www.mouser.com/ds/2/588/AMS_SL13A_Datasheet_EN_v4-371531.pdf

I use the Get Temperature Command command (command code 0xAD).

My code looks like this:

                NfcV nfcvTag = NfcV.get(tag);

                try {
                    nfcvTag.connect();
                } catch (IOException e) {
                    Toast.makeText(getApplicationContext(), "Could not open connection!", Toast.LENGTH_SHORT).show();
                    return;
                }

                try {

                    byte[] comReadTemp = new byte[]{
                            (byte) 0x00, // Flags
                            (byte) 0xAD, // Command: Get Temperature
                            (byte) 0xE0,(byte) 0x36,(byte) 0x04,(byte) 0xCA,(byte) 0x01,(byte) 0x3E,(byte) 0x12,(byte) 0x01, // UID - is this OK?
                    };


                    byte[] userdata = nfcvTag.transceive(comReadTemp);


                    tvText.setText("DATA: " + userdata.length);

                } catch (IOException e) {
                    Toast.makeText(getApplicationContext(), "An error occurred while reading!", Toast.LENGTH_SHORT).show();
                    return;
                }

I am not sure which flags are set, and if I entered the UID parameter correctly in the command.

And also my question: how do I get temperature bits from an answer command? The datasheet shows that the first 8 bits of the command response are flags, the next 16 bits are temperature, and the last 16 bits are CRC. But it seems that I get only 3 bytes in the response ( userdata.lengthequal to 3).

.

0
1

( ), ( , UID), . 0x20.

, :

byte[] comReadTemp = new byte[]{
        (byte) 0x20, // Flags
        (byte) 0xAD, // Command: Get Temperature
        (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,  // placeholder for tag UID
};
System.arraycopy(tag.getId(), 0, comReadTemp, 2, 8);

, transceive(), ISO 15693. , (1 ) (2 ). SOF, CRC EOF NFC ( , ).

, 1..2 userdata :

int tempCode = ((0x003 & userdata[2]) << 8) |
               ((0x0FF & userdata[1]) << 0);
double tempValue = 0.169 * tempCode - 92.7 - 0.169 * 32;

, 32. , .

+1

Source: https://habr.com/ru/post/1684251/


All Articles