Skip to content

TlvEncoder

com.rvi.application.TlvEncoder · Class · SocialCard 1.0.3

Wrap an NDEF message as a Type 2 Tag TLV byte sequence.

Call encode(message) to measure the payload plus its tag-memory overhead, or to prepare an image for an integration that expects a TLV. Write through IReaderService when using SocialCard’s reader connection.

final NDefMessage message = new NDefEncoder().encodeURI("https://rithush.dev");
final byte[] tlv = new TlvEncoder().encode(message);
System.out.printf("%d NDEF bytes, %d TLV bytes%n", message.data().length, tlv.length);
Java imports
import com.rvi.application.NDefEncoder;
import com.rvi.application.TlvEncoder;
import com.rvi.domain.NDefMessage;

A size estimate is possible offline. The repository checks the connected tag’s capacity before writing.

The byte sequence starts with 0x03, uses a one-byte length below 255 bytes and an extended length for larger messages, and ends with 0xFE. ReaderRepository also accounts for page padding when it checks actual tag capacity.

TlvDecoder · NDefMessage · ReaderRepository · CardCapacityException

Method signatures in the Javadoc · All API types