Package org.nfctools.ndef.wkt.handover.records

Examples of org.nfctools.ndef.wkt.handover.records.CollisionResolutionRecord


    HandoverRequestRecord handoverRequestRecord = (HandoverRequestRecord)records.get(0);

    assertEquals(1, handoverRequestRecord.getMajorVersion());
    assertEquals(2, handoverRequestRecord.getMinorVersion());

    CollisionResolutionRecord collisionResolution = handoverRequestRecord.getCollisionResolution();
    assertEquals((0x01 << 8) | 0x02, collisionResolution.getRandomNumber());

    List<AlternativeCarrierRecord> alternativeCarriers = handoverRequestRecord.getAlternativeCarriers();
    assertEquals(1, alternativeCarriers.size());

    AlternativeCarrierRecord alternativeCarrierRecord = alternativeCarriers.get(0);
View Full Code Here


public class CollisionResolutionRecordEncoder implements WellKnownRecordPayloadEncoder {

  @Override
  public byte[] encodePayload(WellKnownRecord wellKnownRecord, NdefMessageEncoder messageEncoder) {

    CollisionResolutionRecord collisionResolutionRecord = (CollisionResolutionRecord)wellKnownRecord;

    int randomNumber = collisionResolutionRecord.getRandomNumber();

    byte[] payload = new byte[] { (byte)((randomNumber >> 8) & 0xFF), (byte)(randomNumber & 0xFF) }; // msb, lsb

    return payload;
  }
View Full Code Here

public class CollisionResolutionRecordDecoder implements WellKnownRecordPayloadDecoder {

  @Override
  public WellKnownRecord decodePayload(byte[] payload, NdefMessageDecoder messageDecoder) {

    CollisionResolutionRecord collisionResolutionRecord = new CollisionResolutionRecord();

    collisionResolutionRecord.setRandomNumber(((payload[0] & 0xFF) << 8) | (payload[1] & 0xFF));

    return collisionResolutionRecord;
  }
View Full Code Here

TOP

Related Classes of org.nfctools.ndef.wkt.handover.records.CollisionResolutionRecord

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.