• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Write Lock Block command for NfcV

I am trying to lock data to a NXP ICODE SLIX SL2S2002 tag type 5 (ISO 15693) to make it readonly by using the WRITE SINGLE BLOCKS command through the NfcV object in an ionic based app:

JavaScript:
   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 don't know which bytes I have to pass for each block. I use the phoneGap-NFC plugin for ionic. Every time I try to set it readonly I get the answer 'Tag was lost' and by the READ_SINGLE_BLOCK command, too. The Ionic method makeReadOnly() does not work because this is blocked by the tag. I have to set it by means of the bytes. I dont know do I have to use Int8Array or Unit8Array, do I have to use reverse() on the tagId because the hex is mirrored or do I just pass the UID bytestring instead of the hexstring?
 
Back
Top Bottom