Exemple #1
0
 public static String decodeDataCodingScheme(Pdu pdu) {
   StringBuffer sb = new StringBuffer();
   switch (PduUtils.extractDcsEncoding(pdu.getDataCodingScheme())) {
     case PduUtils.DCS_ENCODING_7BIT:
       sb.append("7-bit GSM Alphabet");
       break;
     case PduUtils.DCS_ENCODING_8BIT:
       sb.append("8-bit encoding");
       break;
     case PduUtils.DCS_ENCODING_UCS2:
       sb.append("UCS2 encoding");
       break;
   }
   // are flash messages are only applicable to general coding group?
   if ((pdu.getDataCodingScheme() & ~PduUtils.DCS_CODING_GROUP_GENERAL) == 0) {
     if (PduUtils.extractDcsFlash(pdu.getDataCodingScheme()) == PduUtils.DCS_MESSAGE_CLASS_FLASH) {
       sb.append(", (Flash Message)");
     }
   }
   return sb.toString();
 }
Exemple #2
0
 public static byte[] encode7bitUserData(byte[] udhOctets, byte[] textSeptets) {
   // UDH octets and text have to be encoded together in a single pass
   // UDH octets will need to be converted to unencoded septets in order
   // to properly pad the data
   if (udhOctets == null) {
     // convert string to uncompressed septets
     return unencodedSeptetsToEncodedSeptets(textSeptets);
   } else {
     // convert UDH octets as if they were encoded septets
     // NOTE: DO NOT DISCARD THE LAST SEPTET IF IT IS ZERO
     byte[] udhSeptets = PduUtils.encodedSeptetsToUnencodedSeptets(udhOctets, false);
     // combine the two arrays and encode them as a whole
     byte[] combined = new byte[udhSeptets.length + textSeptets.length];
     System.arraycopy(udhSeptets, 0, combined, 0, udhSeptets.length);
     System.arraycopy(textSeptets, 0, combined, udhSeptets.length, textSeptets.length);
     // convert encoded byte[] to a PDU string
     return unencodedSeptetsToEncodedSeptets(combined);
   }
 }
Exemple #3
0
 public static String decodeFirstOctet(Pdu pdu) {
   // Use reflection to check for method signatures hasTpXXX() and getTpXXX()
   // that are specific to a particular type in actual object
   StringBuffer sb = new StringBuffer();
   sb.append("First Octet: " + PduUtils.byteToPdu(pdu.getFirstOctet()));
   sb.append(" [");
   // TP-MTI
   switch (pdu.getTpMti()) {
     case PduUtils.TP_MTI_SMS_DELIVER:
       sb.append("TP-MTI: (SMS-DELIVER)");
       break;
     case PduUtils.TP_MTI_SMS_STATUS_REPORT:
       sb.append("TP-MTI: (SMS-STATUS REPORT)");
       break;
     case PduUtils.TP_MTI_SMS_SUBMIT:
       sb.append("TP-MTI: (SMS-SUBMIT)");
       break;
     default:
       throw new RuntimeException("Invalid message type");
   }
   // TP-MMS
   if (hasTpField(pdu, "TpMms") != null) {
     if (hasTpField(pdu, "TpMms")) {
       sb.append(", TP-MMS: (Has more messages)");
     } else {
       sb.append(", TP-MMS: (has no messages)");
     }
   }
   // TP-RD
   if (hasTpField(pdu, "TpRd") != null) {
     if (hasTpField(pdu, "TpRd")) {
       sb.append(", TP-RD: (Reject duplicates)");
     } else {
       sb.append(", TP-RD: (allow duplicates)");
     }
   }
   // TP-VPF
   if ((hasTpField(pdu, "TpVpf") != null) && (hasTpField(pdu, "TpVpf") != false)) {
     switch (getTpField(pdu, "TpVpf")) {
       case PduUtils.TP_VPF_INTEGER:
         sb.append(", TP-VPF: (validity format, integer");
         break;
       case PduUtils.TP_VPF_TIMESTAMP:
         sb.append(", TP-VPF: (validity format, timestamp");
         break;
       case PduUtils.TP_VPF_NONE:
         sb.append(", TP-VPF: (validity format, none)");
         break;
     }
   }
   // TP-SRI
   if (hasTpField(pdu, "TpSri") != null) {
     if (hasTpField(pdu, "TpSri")) {
       sb.append(", TP-SRI: (Requests Status Report)");
     } else {
       sb.append(", TP-SRI: (No Status Report)");
     }
   }
   // TP-SRR
   if (hasTpField(pdu, "TpSrr") != null) {
     if (hasTpField(pdu, "TpSrr")) {
       sb.append(", TP-SRR: (Requests Status Report)");
     } else {
       sb.append(", TP-SRR: (No Status Report)");
     }
   }
   // TP-UDHI
   if (pdu.hasTpUdhi()) {
     sb.append(", TP-UDHI: (has UDH)");
   } else {
     sb.append(", TP-UDHI: (no UDH)");
   }
   sb.append("]");
   sb.append("\n");
   return sb.toString();
 }
 @Override
 public String getPduUserData() {
   return PduUtils.bytesToPdu(getDataBytes());
 }