Package org.nfctools.tags

Examples of org.nfctools.tags.TagOutputStream


public class TlvTest {

  @Test
  public void testTlvWriter() throws Exception {

    TagOutputStream out = new TagOutputStream(7);
    TypeLengthValueWriter writer = new TypeLengthValueWriter(out);

    writer.write(new NdefMessageTlv(new byte[] { 0x01, 0x02, 0x03, 0x04 }));
    writer.close();

    byte[] writtenData = out.getBuffer();

    byte[] expectedData = { 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, (byte)0xFE };

    assertArrayEquals(expectedData, writtenData);
View Full Code Here


    expectedData[1] = (byte)0xFF;
    expectedData[2] = 0x04;
    expectedData[3] = 0x00;
    expectedData[1028] = (byte)0xFE;

    TagOutputStream out = new TagOutputStream(1029);
    TypeLengthValueWriter writer = new TypeLengthValueWriter(out);

    writer.write(new NdefMessageTlv(largeData));
    writer.close();

    byte[] writtenData = out.getBuffer();

    assertArrayEquals(expectedData, writtenData);

  }
View Full Code Here

      throw new NfcException(e);
    }
  }

  private byte[] wrapNdefMessageWithTlv(byte[] ndefMessage, int maxSize) {
    TagOutputStream out = new TagOutputStream(maxSize);
    TypeLengthValueWriter writer = new TypeLengthValueWriter(out);
    writer.write(new NdefMessageTlv(ndefMessage));
    writer.close();
    return out.getBuffer();
  }
View Full Code Here

      throw new NfcException(e);
    }
  }

  private byte[] convertNdefMessage(Record... records) {
    TagOutputStream out = new TagOutputStream(getMaxSize());
    TypeLengthValueWriter writer = new TypeLengthValueWriter(out);
    if (memoryLayout.hasDynamicLockBytes()) {
      writer.write(memoryLayout.createLockControlTlv());
    }
    writer.write(new NdefMessageTlv(convertRecordsToBytes(records)));
    writer.close();
    return out.getBuffer();
  }
View Full Code Here

    trailerBlock.setGeneralPurposeByte(MfConstants.NDEF_GPB_V10_READ_WRITE);
    return trailerBlock;
  }

  private byte[] wrapNdefMessageWithTlv(byte[] ndefMessage, int maxSize) {
    TagOutputStream out = new TagOutputStream(maxSize);
    TypeLengthValueWriter writer = new TypeLengthValueWriter(out);
    writer.write(new NdefMessageTlv(ndefMessage));
    writer.close();

    return out.getBuffer();
  }
View Full Code Here

TOP

Related Classes of org.nfctools.tags.TagOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.