Seeking to make data on a NXP ICODE SLIX SL2S2002 tag type 5 (ISO 15693) read-only by utilizing the WRITE SINGLE BLOCKS command through the NfcV object in an app based on Ionic:
private readonly cmdISO15693 = {
READ_SINGLE_BLOCK: 0x20,
WRITE_SINGLE_BLOCK: 0x21,
LOCK_BLOCK: 0x22
};
this.nfc.connect('android.nfc.tech.NfcV', 500)
.then(
(data) => {
console.log('connected to', this.nfc.bytesToHexString(tag.id.reverse()).toUpperCase());
console.log('maxTransceiveLength: ', data);
const offset = 0; // offset of first block to read
const blocks = 8; // number of blocks to read
const bytesOfText: number[] = this.nfc.stringToBytes(text);
console.log('bytesOfText: ', bytesOfText);
console.log('hex string: ', this.nfc.bytesToHexString(bytesOfText));
let cmd = new Int8Array([
0x60, // 0: flags: addressed (= UID field present) or 0x90 0x60 0x40 0x20??
this.cmdISO15693.READ_SINGLE_BLOCK, // 1: command
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 2-9 placeholder for tag UID
0x00 // 10: block number
// 0x00, 0x00, 0x00, 0x00 // 11- DATA
// ((blocks - 1) & 0x0ff) // number of blocks (-1 as 0x00 means one block)
]);
console.log('cmd: ', [...cmd]);
// tag uid in which direction
cmd = arrayCopy(tag.id.reverse(), 0, cmd, 2, 8);
console.log('cmd new: ', [...cmd]);
console.log('cmd buffer: ', cmd.buffer);
// arrayCopy(bytesOfText, 0, cmd, 11, 4);
this.nfc.transceive(cmd.buffer)
.then((res: ArrayBuffer) => {
console.log('transceive result:', res);
try {
console.log(Utf8ArrayToStr(res));
} catch (e) {
console.log('Utf8ArrayToStr not possible', e);
}
this.nfc.close().then(() => console.log('closed connection'))
.catch((err) => console.log('error closing', err));
})
.catch((err) => {
console.log('error while transceive', err);
this.displayToast('Error to write the RFID-Chips.', 'warning');
});
I'm unsure about the correct byte values to pass for each block. Using the phoneGap-NFC plugin for Ionic. When attempting to set it as read-only, the response 'Tag was lost' is returned, even with the READ_SINGLE_BLOCK command. The method makeReadOnly() in Ionic does not function due to tag restrictions. Setting it using bytes seems necessary. Uncertain whether to use Int8Array or Unit8Array, if applying reverse() on the tagId due to mirrored hex, or simply passing the UID bytestring instead of the hexstring.