AlternativeCarrierRecord alternativeCarrierRecord = (AlternativeCarrierRecord)wellKnownRecord;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
// cps
CarrierPowerState carrierPowerState = alternativeCarrierRecord.getCarrierPowerState();
if (carrierPowerState == null) {
throw new NdefEncoderException("Expected carrier power state", alternativeCarrierRecord);
}
bout.write(carrierPowerState.getValue() & 0x7); // 3 lsb
// carrier data reference: 1
String carrierDataReference = alternativeCarrierRecord.getCarrierDataReference();
if (carrierDataReference == null) {
throw new NdefEncoderException("Expected carrier data reference", alternativeCarrierRecord);