public static byte toSubmitInfo()

in ch-commons-gsm/src/main/java/com/cloudhopper/commons/gsm/GsmUtil.java [78:147]


    public static byte toSubmitInfo(boolean replyPath, boolean udhIndicator,
            boolean deliveryReceipt, int validityPeriodFormat, boolean rejectDuplicates)
            throws IllegalArgumentException {

        // generate proper submit info
        byte info = 0;

        // 7 0 TP-Reply -Path Reply path no set
        if (replyPath) {
            info |= (1 << 7);
        }

        // 6 0 TP-User-Data -header-indicator Indication that user data doesn't contain additional header.
        if (udhIndicator) {
            info |= (1 << 6);
        }

        // 5 0 TP-Status -Report-Request Not requested
        if (deliveryReceipt) {
            info |= (1 << 5);
        }

        // 4 1 TP-Validity -Period-Format Relative format (bits 4 and 3)
        // 3 0 TP-Validity -Period-Format Relative format (bits 4 and 3)
        //			4 3 (bits)
        //			0 0 TP-VP field not present
        //			1 0 TP-VP field present - relative format
        //			0 1 TP-VP field present - enhanced format
        //			1 1 TP-VP field present - absolute format
        if (validityPeriodFormat == GsmConstants.VP_FORMAT_RELATIVE) {
            info |= (1 << 4);
        } else if (validityPeriodFormat == GsmConstants.VP_FORMAT_ENHANCED) {
            info |= (1 << 3);
        } else if (validityPeriodFormat == GsmConstants.VP_FORMAT_ABSOLUTE) {
            info |= (1 << 4);
            info |= (1 << 3);
        } else if (validityPeriodFormat == GsmConstants.VP_FORMAT_NONE) {
            // zero by default so we don't add any bits
        } else {
            throw new IllegalArgumentException("Invalid validity period format");
        }

        // 2 0 TP-Rejected -Dublicates Do not reject duplicates in SC
        //		- 0 Instruct the SC to accept an SMS-SUBMIT for an SM still held in the
        //		SC which has the same TP-MR and the same TP-DA as a previously submitted SM from the
        //		same OA.
        //		- 1 Instruct the SC to reject an SMS-SUBMIT for an SM still held in the
        //		SC which has the same TP-MR and the same TP-DA as the previously submitted SM from the
        //		same OA. In this case an appropriate TP-FCS value will be returned in the
        //		SMS-SUBMIT-REPORT.
        if (rejectDuplicates) {
            info |= (1 << 2);
        }

        // 1 0 TP-Message -Type-Indicator type:SMS-SUBMIT (from phone to network), (bits 1 and 0)
        // 0 1 TP-Message -Type-Indicator type:SMS-SUBMIT (from phone to network), (bits 1 and 0)
        /**
        0 0 SMS-DELIVER (in the direction SC to MS)
        0 0 SMS-DELIVER REPORT (in the direction MS to SC)
        1 0 SMS-STATUS-REPORT (in the direction SC to MS)
        1 0 SMS-COMMAND (in the direction MS to SC)
        0 1 SMS-SUBMIT (in the direction MS to SC)
        0 1 SMS-SUBMIT-REPORT (in the direction SC to MS)
        1 1 Reserved
         */
        // set to SMS-SUBMIT
        info |= (1 << 0);

        return info;
    }