Hi,
Have you downloaded the source code of our "ST25 NFC Tap" application? It contains lot of examples showing all the features of our NFC Tags. You can get it here:
https://www.st.com/en/embedded-software/stsw-st25001.html
You can then look at the class "ST25DVChangePermissionsActivity". This is the class managing the change of permissions for ST25DV areas. You can look at the function changePermission().
I see now that there is in fact a simpler manner to set the permissions. In this function, we are accessing directly to the ST25DV Registers. It is in fact simpler to use a generic interface supported by ST25DVTags. This is the "MultiAreaInterface" defined in ST25 SDK. Here is some pseudo code showing the idea:
// Configuration password should be entered before changing the ST25DV configuration
final byte[] configurationPassword = PUT_YOUR_PASSWORD_HERE;
int configurationPasswordNumber = st25DVTag.getConfigurationPasswordNumber();
st25DVTag.presentPassword(configurationPasswordNumber, configurationPassword);
// Set a password for Area1. We choose Password 0
int area1PasswordNumber = 0;
st25DVTag.setPasswordNumber(MultiAreaInterface.AREA1, area1PasswordNumber);
// Set Area1 protection
st25DVTag.setReadWriteProtection(MultiAreaInterface.AREA1, READABLE_AND_WRITE_IMPOSSIBLE);
The Write is now password protected.
If someone wants to write into this area, he should first enter the area password. Look how it is done in presentPassword() of "ST25DVPresentPwdActivity".
For your information, the calls to ST25 SDK should be done from a background Thread or from an Async Task. If you try to call the SDK from the UI Thread you will get an exception because it is not allowed to block the UI Thread for a too long time.
By the way, when reading or writing into an Area with the functions readBytes() and writeBytes(), you will get an exception if the area is protected by password (in read or in write). You can catch the exceptions ISO15693_BLOCK_PROTECTED and ISO15693_BLOCK_IS_LOCKED and display a popup requesting the Area password. If the password is presented successfully, you can try to read or write again.
Best regards