1. Are you ready for the Galaxy S20? Here is everything we know so far!

Write Lock Block command for NfcV

Discussion in 'Android Development' started by Daniel1996, Nov 27, 2020.

  1. Daniel1996

    Daniel1996 Lurker
    Thread Starter

    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:

    Code (Javascript):
    1.    private readonly cmdISO15693 = {
    2.    READ_SINGLE_BLOCK: 0x20,
    3.    WRITE_SINGLE_BLOCK: 0x21,
    4.    LOCK_BLOCK: 0x22
    5. };
    6.  
    7. this.nfc.connect('android.nfc.tech.NfcV', 500)
    8.      .then(
    9.        (data) => {
    10.            console.log('connected to', this.nfc.bytesToHexString(tag.id.reverse()).toUpperCase());
    11.            console.log('maxTransceiveLength: ', data);
    12.  
    13.            const offset = 0; // offset of first block to read
    14.            const blocks = 8; // number of blocks to read
    15.            const bytesOfText: number[] = this.nfc.stringToBytes(text);
    16.            console.log('bytesOfText: ', bytesOfText);
    17.            console.log('hex string: ', this.nfc.bytesToHexString(bytesOfText));
    18.  
    19.            let cmd = new Int8Array([
    20.                0x60, // 0: flags: addressed (= UID field present) or 0x90 0x60 0x40 0x20??
    21.                this.cmdISO15693.READ_SINGLE_BLOCK, // 1: command
    22.                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // 2-9 placeholder for tag UID
    23.                0x00  // 10: block number
    24.                // 0x00, 0x00, 0x00, 0x00  // 11- DATA
    25.                // ((blocks - 1) & 0x0ff)  // number of blocks (-1 as 0x00 means one block)
    26.            ]);
    27.            console.log('cmd: ', [...cmd]);
    28.  
    29.            // tag uid in which direction
    30.            cmd = arrayCopy(tag.id.reverse(), 0, cmd, 2, 8);
    31.            console.log('cmd new: ', [...cmd]);
    32.            console.log('cmd buffer: ', cmd.buffer);
    33.            // arrayCopy(bytesOfText, 0, cmd, 11, 4);
    34.  
    35.            this.nfc.transceive(cmd.buffer)
    36.              .then((res: ArrayBuffer) => {
    37.                  console.log('transceive result:', res);
    38.                  try {
    39.                      console.log(Utf8ArrayToStr(res));
    40.                  } catch (e) {
    41.                      console.log('Utf8ArrayToStr not possible', e);
    42.                  }
    43.  
    44.                  this.nfc.close().then(() => console.log('closed connection'))
    45.                    .catch((err) => console.log('error closing', err));
    46.              })
    47.              .catch((err) => {
    48.                  console.log('error while transceive', err);
    49.                  this.displayToast('Error to write the RFID-Chips.', 'warning');
    50.              });
    51. }

    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?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - Write Lock Block
  1. sukhreetsingh
    Replies:
    2
    Views:
    123
  2. clefo
    Replies:
    6
    Views:
    805
  3. Musician888
    Replies:
    0
    Views:
    323
  4. FoxMulder
    Replies:
    0
    Views:
    487
  5. akkha
    Replies:
    2
    Views:
    763
  6. restore reset reinstall
    Replies:
    1
    Views:
    342
  7. livingneanderthal
    Replies:
    5
    Views:
    1,182
  8. Utkarsh4
    Replies:
    0
    Views:
    1,352
  9. stoned frog
    Replies:
    2
    Views:
    1,294
  10. Soumyaranjan Pal
    Replies:
    3
    Views:
    498

Share This Page

Loading...