0

In my App (Android studio java) I'm trying to read a payload from a specific tag with result of type ndefFormatable and NfcV. Once I get the intent and identify the tag by: Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); I then create a NFCV object and do the following operation:

            NfcV nfcV = NfcV.get(tag);
            byte[] data = new byte[0];

            byte[] id = tag.getId();

            if (nfcV != null) {

                byte[] infoCmd = new byte[2 + id.length];
                // set "addressed" flag
                infoCmd[0] = 0x20;
                //   Get System Information command byte
                infoCmd[1] = 0x2B;
                //adding the tag id
                System.arraycopy(id, 0, infoCmd, 2, id.length);

                System.arraycopy(id, 0, infoCmd, 2, 8);
                try {
                    nfcV.connect();
//                  infoCmd VALUE: [32, 43, 107, 32, -61, -97, 116, 77, 2, -32]
//                  DATA RESULT:   [0, 11, 107, 32, -61, -97, 116, 77, 2, -32, -1, 0, 78]
                    data = nfcV.transceive(infoCmd);


                }
                catch (IOException e) {
                    e.printStackTrace();
                }
                finally {
                    try {
                        nfcV.close();
                    }
                    catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }

The problem is that the data I receive from the nfc.transceive is not what I expect it to be, I don't know if it is because the content of infoCmd is wrong or simply because like this I cannot get the payload from the device. If it can help I want to clarify that with this exact nfc device, in an other c# code I am able to get the payload with the ProximityDevice Object by:

ProximityMessage message;
var rawMsg = message.Data.ToArray();

And I must replicate this exact result (rawMsg) in my Android app, basically I'm trying to get the same payload sent from the same nfc device but in an other app, in this case Android.

3
  • You really need specify the make and model of the NfcV Tag so that the datasheet can be referenced. Also my understanding is that Android "Selects" the Tag, there is no need to use the "addressed" flag, you are not operating with the Tag at that level. Try just transceive the InfoCmd. Commented Mar 1, 2024 at 17:24
  • "* the data I receive from the nfc.transceive is not what I expect*" - it could be of great help to us if you would share the data you received from the tag and what you expected to get, thanks. Commented Mar 2, 2024 at 20:16
  • @MichaelFehr as i already wrote in the post, the value i received is commented ad //DATA RESULT and I simply expect to get the same bytes from the payload i get in the c# app, it would be good for me to just know if what im trying to do to get the payload is right Commented Mar 5, 2024 at 8:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.