Closed brentrbutcher closed 9 months ago
If I remember correctly you could write the Static Lock bytes (2, 3) on the information block (2) (See NFCForum-TS-Type-2-Tag_1.1.pdf#2.1.2) The idea here would be to start on block 2 instead of block 4 if there is some lock flag to pass.
For the implem this, for instance, could be done this way
// Prepare the buffer to write on the card
const rawDataToWrite = nfcCard.prepareBytesToWrite(message);
// Write the buffer on the card starting at block 4
// ~~const preparationWrite = await reader.write(2, rawDataToWrite.preparedData);~~
// Prefer computing the start block internally and pass a flag to lock/not lock
// Lock => Start at block 2, No lock => start at 4
const preparationWrite = await reader.write({ ndef: rawDataToWrite.preparedData, lock: true })
Hope this helps,
I would review your PR if you wish to push one.
I totally would, but I am way under qualified. Theoretically, if I tried to do this in my own application how could I do it?
I am seeing that bytes 2 and 3 of block 2 must be set to 1b to ostensibly lock the tag. How could I go about that? I would love to try to write the PR if I can figure it out in my own application first.
Did you check this issue @brentrbutcher?
You are right about bytes 2 & 3 of block 2, it should be 0x01
and 0xff
iirc.
The buffer to write is prepared here fyi.
I will try to take some time to work on the lib in the next weeks.
Have a good day!
Is there a method for locking nfc cards? Thanks.