Skip to main content
Visitor II
September 19, 2022
Solved

read memory of ST25DV64K-I using android studio

  • September 19, 2022
  • 1 reply
  • 955 views

I want create one app that with NFC read the memory of ST25DV64K-I.

i try the official app ST25 and read the memory... but using the st25sdk-1.10.0 libraries.

i use android studio.i can read the Tag name and UID, but i can't find how to read the memory

    This topic has been closed for replies.
    Best answer by France Berthelot

    Hello

    With our application you can read memory.

    Feature used is : when tag has been tapped, you use Memory content feature/menu to R/W/Dump memory

    Source code is available here: https://www.st.com/en/embedded-software/stsw-st25001.html

    Here an extract from the source code as example using our SDK and for different Tag type

    Assuming : NFCTag mTag;

    if (UIHelper.isAType4Tag(mTag)) {

       // Tag type 4

       int size = getMemoryAreaSizeInBytes(((Type4Tag) mTag), mArea);

       mNumberOfBytes = size;

       mStartAddress = 0;

       int fileId = UIHelper.getType4FileIdFromArea(mArea);

       // inform user that a read will be performed

       snackBarUiThread();

       if (mReadPassword != null && mTag instanceof STType4Tag) {

           mBuffer = ((STType4Tag) mTag).readBytes(fileId, 0, size, mReadPassword);

       } else {

           mBuffer = ((Type4Tag) mTag).readBytes(fileId, 0, size);

       }

       mReadPassword = null;

       int nbrOfBytesRead = 0;

       if (mBuffer != null) {

           nbrOfBytesRead = mBuffer.length;

       }

       if (nbrOfBytesRead != mNumberOfBytes) {

           showToast(R.string.error_during_read_operation, nbrOfBytesRead);

       }

    } else if (UIHelper.isAType5Tag(mTag)){

       if (mArea == -1) {

           mAreaId = getAreaIdFromAddressInBytesForType5Tag(mStartAddress);

       }

       if (mAreaId == -1) {

           // An issue occured retrieving AreaId from Address

           // Address is probably invalid

           showToast(R.string.invalid_value);

           return false;

       } else {

           // Type 5

           mBuffer = getTag().readBytes(mStartAddress, mNumberOfBytes);

           // Warning: readBytes() may return less bytes than requested

           int nbrOfBytesRead = 0;

           if (mBuffer != null) {

               nbrOfBytesRead = mBuffer.length;

           }

           if (nbrOfBytesRead != mNumberOfBytes) {

               showToast(R.string.error_during_read_operation, nbrOfBytesRead);

           }

       }

    } else if (UIHelper.isAType2Tag(mTag)){

       if (mArea == -1) {

           mAreaId = getAreaIdFromAddressInBytesForType2Tag(mStartAddress);

       }

       if (mAreaId == -1) {

           // An issue occured retrieving AreaId from Address

           // Address is probably invalid

           showToast(R.string.invalid_value);

           return false;

       } else {

           mBuffer = getTag().readBytes(mStartAddress, mNumberOfBytes);

           // Warning: readBytes() may return less bytes than requested

           int nbrOfBytesRead = 0;

           if (mBuffer != null) {

               nbrOfBytesRead = mBuffer.length;

           }

           if (nbrOfBytesRead != mNumberOfBytes) {

               showToast(R.string.error_during_read_operation, nbrOfBytesRead);

           }

       }

    Search file : ReadFragmentActivity in source code, and you will found way of doing memory read.

    For write refers to WriteFragmentActivity

    Rgds,FB

    1 reply

    ST Employee
    September 27, 2022

    Hello

    With our application you can read memory.

    Feature used is : when tag has been tapped, you use Memory content feature/menu to R/W/Dump memory

    Source code is available here: https://www.st.com/en/embedded-software/stsw-st25001.html

    Here an extract from the source code as example using our SDK and for different Tag type

    Assuming : NFCTag mTag;

    if (UIHelper.isAType4Tag(mTag)) {

       // Tag type 4

       int size = getMemoryAreaSizeInBytes(((Type4Tag) mTag), mArea);

       mNumberOfBytes = size;

       mStartAddress = 0;

       int fileId = UIHelper.getType4FileIdFromArea(mArea);

       // inform user that a read will be performed

       snackBarUiThread();

       if (mReadPassword != null && mTag instanceof STType4Tag) {

           mBuffer = ((STType4Tag) mTag).readBytes(fileId, 0, size, mReadPassword);

       } else {

           mBuffer = ((Type4Tag) mTag).readBytes(fileId, 0, size);

       }

       mReadPassword = null;

       int nbrOfBytesRead = 0;

       if (mBuffer != null) {

           nbrOfBytesRead = mBuffer.length;

       }

       if (nbrOfBytesRead != mNumberOfBytes) {

           showToast(R.string.error_during_read_operation, nbrOfBytesRead);

       }

    } else if (UIHelper.isAType5Tag(mTag)){

       if (mArea == -1) {

           mAreaId = getAreaIdFromAddressInBytesForType5Tag(mStartAddress);

       }

       if (mAreaId == -1) {

           // An issue occured retrieving AreaId from Address

           // Address is probably invalid

           showToast(R.string.invalid_value);

           return false;

       } else {

           // Type 5

           mBuffer = getTag().readBytes(mStartAddress, mNumberOfBytes);

           // Warning: readBytes() may return less bytes than requested

           int nbrOfBytesRead = 0;

           if (mBuffer != null) {

               nbrOfBytesRead = mBuffer.length;

           }

           if (nbrOfBytesRead != mNumberOfBytes) {

               showToast(R.string.error_during_read_operation, nbrOfBytesRead);

           }

       }

    } else if (UIHelper.isAType2Tag(mTag)){

       if (mArea == -1) {

           mAreaId = getAreaIdFromAddressInBytesForType2Tag(mStartAddress);

       }

       if (mAreaId == -1) {

           // An issue occured retrieving AreaId from Address

           // Address is probably invalid

           showToast(R.string.invalid_value);

           return false;

       } else {

           mBuffer = getTag().readBytes(mStartAddress, mNumberOfBytes);

           // Warning: readBytes() may return less bytes than requested

           int nbrOfBytesRead = 0;

           if (mBuffer != null) {

               nbrOfBytesRead = mBuffer.length;

           }

           if (nbrOfBytesRead != mNumberOfBytes) {

               showToast(R.string.error_during_read_operation, nbrOfBytesRead);

           }

       }

    Search file : ReadFragmentActivity in source code, and you will found way of doing memory read.

    For write refers to WriteFragmentActivity

    Rgds,FB