RFID Printing
This guide explains how to print labels and simultaneously encode RFID inlays using the AD Device Manager SDK.
Supported Devices
RFID print-and-encode is supported on:
| Device | SDK type | RFID hardware required |
|---|---|---|
| PF Edge | NG/TSC | Yes — must be present on unit |
| PF6059 | CDIL | Yes — must be present on unit |
Not all units include RFID hardware. Always check for capability at runtime before attempting any RFID operation.
Checking for RFID Support
The SDK uses a capability pattern. Use hasCapability() and isRFIDEnabled() before calling any RFID method:
import com.averydennison.addevicemanager.capabilities.RfidCapability;
PrinterAdapter printerAdapter = deviceAdapter.getPrinterAdapter();
if (printerAdapter.hasCapability(RfidCapability.class)
&& ((RfidCapability) printerAdapter).isRFIDEnabled()) {
RfidCapability rfid = (RfidCapability) printerAdapter;
// Safe to call RFID methods
} else {
logger.warn("This device does not support RFID.");
}
Print and Encode an RFID Tag
Use printAndEncodeRfid() to print a label template and write data to the RFID inlay in a single operation.
Method Signature
CompletableFuture<Void> printAndEncodeRfid(
String templateName, // Template resource name
String variableData, // Template variables: "KEY1=VALUE1;KEY2=VALUE2"
int qty, // Number of labels to print (0 defaults to 1)
String epcData, // EPC memory bank data as hex string (null to skip)
String userMemory, // User memory bank data as hex string (null to skip)
String accessPwd, // Access password as hex string (null to skip)
String killPwd, // Kill password as hex string (null to skip)
String lockCode // Lock code for EPC write ("0" for no lock)
);
Device-specific Template Notes
| Device | Template extension | Template location |
|---|---|---|
| PF Edge | .ngt | Loaded in app memory via resource management |
| PF6059 | .lnt | Registered on the printer via resource management |
Example: Print and Encode with EPC
PrinterAdapter printerAdapter = deviceAdapter.getPrinterAdapter();
if (printerAdapter.hasCapability(RfidCapability.class)
&& ((RfidCapability) printerAdapter).isRFIDEnabled()) {
RfidCapability rfid = (RfidCapability) printerAdapter;
String template = "RFIDLabel.ngt"; // Use ".lnt" for PF6059
String variableData = "VAR1=00614141000015";
String epcData = "3034257BF40A800000000001"; // 96-bit SGTIN-96 hex
String lockCode = "0"; // No lock
rfid.printAndEncodeRfid(template, variableData, 1, epcData, null, null, null, lockCode)
.thenRun(() -> logger.info("RFID label printed and encoded successfully."))
.exceptionally(e -> {
logger.error("RFID print+encode failed: " + e.getMessage());
return null;
});
}
Parameters Reference
| Parameter | Description | Example |
|---|---|---|
templateName | Name of the template resource registered on the device | "RFIDLabel.ngt" / "RFIDLabel.lnt" |
variableData | Semicolon-separated key=value pairs for template placeholders | "VAR1=123456789012" |
qty | Number of labels to print. Pass 0 to default to 1 | 1 |
epcData | EPC memory bank content as a hexadecimal string. null to skip | "3034257BF40A800000000001" |
userMemory | User memory bank content as a hex string. null to skip | null |
accessPwd | 32-bit access password as hex. null to skip | null |
killPwd | 32-bit kill password as hex. null to skip | null |
lockCode | Lock code applied after EPC write. Use "0" for no lock | "0" |
Generating an EPC from an EAN-13
A common use case is encoding a GS1 SGTIN-96 EPC derived from an EAN-13 barcode. The Quick Start application includes a utility method for this:
// ean13: 12 or 13 digit EAN-13 string
// serialNumber: a unique counter incremented per label printed
String epc = Utils.ean13ToEpcSgtin96("4006381333931", serialCounter);
// Returns a 24-character uppercase hex string, e.g. "3034257BF40A800000000001"
// Returns null if the EAN-13 is invalid
The encoding follows GS1 EPC TDS SGTIN-96 with the following bit layout:
| Field | Bits | Value |
|---|---|---|
| Header | 8 | 0x30 (SGTIN-96) |
| Filter | 3 | 1 (retail consumer item) |
| Partition | 3 | 5 (7-digit company prefix + 5-digit item ref) |
| Company Prefix | 24 | First 7 digits of EAN-13 |
| Item Reference | 20 | Digits 8–12 of EAN-13 |
| Serial | 38 | Unique serial counter (up to 274 billion) |
Note: Partition 5 (7+5 digit split) is the most common for standard European EAN-13. If your company prefix has a different length, the partition value and bit widths must be adjusted accordingly.
RFID Power Configuration
You can read and adjust the antenna power levels for both read and write operations.
Power Ranges
| Device | Read power range | Write power range |
|---|---|---|
| PF Edge | 1 to 27 | 1 to 27 |
| PF6059 | -15 to 23 | -15 to 23 |
Reading Current Power Levels
RfidCapability rfid = (RfidCapability) printerAdapter;
rfid.getReadRfidPower()
.thenAccept(power -> logger.info("Current read power: " + power))
.exceptionally(e -> { logger.error("Failed: " + e.getMessage()); return null; });
rfid.getWriteRfidPower()
.thenAccept(power -> logger.info("Current write power: " + power))
.exceptionally(e -> { logger.error("Failed: " + e.getMessage()); return null; });
Setting Power Levels
// PF Edge: valid range 1–27. PF6059: valid range -15 to 23.
rfid.setReadRfidPower(10)
.thenRun(() -> logger.info("Read power set."))
.exceptionally(e -> { logger.error("Failed: " + e.getMessage()); return null; });
rfid.setWriteRfidPower(10)
.thenRun(() -> logger.info("Write power set."))
.exceptionally(e -> { logger.error("Failed: " + e.getMessage()); return null; });
Note (PF Edge): The TSC SDK's
RFID POWERcommand requires both read and write values simultaneously. When you callsetReadRfidPower(), the SDK automatically fetches the current write power to keep it unchanged, and vice versa.
RFID Calibration
Calibration should be performed when installing new RFID media or after changing the roll position.
| Device | What calibrateRFID() does |
|---|---|
| PF Edge | Sends a single RFID calibration command to the printer |
| PF6059 | Runs a standard media calibration first, then auto-calibrates the RFID antenna power |
RfidCapability rfid = (RfidCapability) printerAdapter;
rfid.calibrateRFID()
.thenRun(() -> logger.info("RFID calibration complete."))
.exceptionally(e -> {
logger.error("RFID calibration failed: " + e.getMessage());
return null;
});
Important: Always run
calibrateRFID()after loading a new roll of RFID media to ensure reliable tag encoding.
Error Handling
RFID operations return a CompletableFuture. Common failure scenarios:
| Scenario | Exception message |
|---|---|
| Device has no RFID hardware | "This device does not have RFID hardware." |
| Template not found (PF Edge) | "Template '<name>' not found in memory." |
| EPC encoding fails | "RFID print operation failed" |
| Operation times out (PF6059) | "RFID print operation timed out" |
| Invalid EAN-13 passed to EPC helper | Method returns null — check before passing to SDK |
rfid.printAndEncodeRfid(template, data, 1, epc, null, null, null, "0")
.exceptionally(e -> {
Throwable cause = e.getCause() != null ? e.getCause() : e;
if (cause instanceof UnsupportedOperationException) {
logger.error("RFID not supported on this device.");
} else {
logger.error("RFID operation failed: " + cause.getMessage());
}
return null;
});
Next Steps
- Printing - Standard (non-RFID) label printing
- Callbacks - Monitor print progress with
PrintProgressCallback - Resource Management - Register RFID label templates