def __get_msg_pdu(self, text, msgvp): #Data coding Scheme data_coding_scheme = "" if gsm0338.is_valid_gsm_text(text): text_format = SEVENBIT_FORMAT data_coding_scheme = 0x00 | SEVENBIT_FORMAT else: text_format = UNICODE_FORMAT data_coding_scheme = 0x00 | UNICODE_FORMAT data_coding_scheme_pdu = ''.join( ["%02x" % ord(n) for n in chr(data_coding_scheme)]) #Validity period valid_period = msgvp & 0xFF valid_period_pdu = ''.join( ["%02x" % ord(n) for n in chr(valid_period)]) #UDL + UD message_pdu = "" if text_format == SEVENBIT_FORMAT: if len(text) <= 160: print "GSM0338 (len %s)" % len(text) message_pdu = [self.__pack_8bits_to_7bits(text)] else: print "GSM0338 (len %s multipart)" % len(text) message_pdu = self.__split_sms_message( text, encoding=SEVENBIT_FORMAT, limit=160) else: if len(text) <= 70: print "UNICODE (len %s)" % len(text) message_pdu = [self.__pack_8bits_to_ucs2(text)] else: print "UNICODE (len %s)" % len(text) message_pdu = self.__split_sms_message(text, encoding=UNICODE_FORMAT, limit=70) ret_msgs_list = [] for msg in message_pdu: ret_msgs_list.append(data_coding_scheme_pdu + valid_period_pdu + msg) return ret_msgs_list
def _get_msg_pdu(self, text, validity_period, store): # Data coding scheme dcs = "" if gsm0338.is_valid_gsm_text(text): text_format = SEVENBIT_FORMAT dcs = 0x00 | SEVENBIT_FORMAT else: text_format = UNICODE_FORMAT dcs = 0x00 | UNICODE_FORMAT dcs_pdu = ''.join(["%02x" % ord(n) for n in chr(dcs)]) # Validity period if not store: if (validity_period & ~SMS_VALIDITY_PERIOD_MASK) == 0: msgvp = validity_period msgvp_pdu = ''.join(["%02x" % ord(n) for n in chr(msgvp)]) else: msgvp_pdu = '' # UDL + UD message_pdu = "" if text_format == SEVENBIT_FORMAT: if len(text) <= SEVENBIT_SIZE: message_pdu = [self._pack_8bits_to_7bits(text)] else: message_pdu = self._split_sms_message(text, limit=SEVENBIT_SIZE, encoding=SEVENBIT_FORMAT) else: if len(text) <= UCS2_SIZE: message_pdu = [self._pack_8bits_to_ucs2(text)] else: message_pdu = self._split_sms_message(text, limit=UCS2_SIZE, encoding=UNICODE_FORMAT) ret = [] for msg in message_pdu: if store: ret.append(dcs_pdu + msg) else: ret.append(dcs_pdu + msgvp_pdu + msg) return ret
def __get_msg_pdu(self, text, msgvp): #Data coding Scheme data_coding_scheme = "" if gsm0338.is_valid_gsm_text(text): text_format = SEVENBIT_FORMAT data_coding_scheme = 0x00 | SEVENBIT_FORMAT else: text_format = UNICODE_FORMAT data_coding_scheme = 0x00 | UNICODE_FORMAT data_coding_scheme_pdu = ''.join(["%02x" % ord(n) for n in chr(data_coding_scheme)]) #Validity period valid_period = msgvp & 0xFF valid_period_pdu = ''.join(["%02x" % ord(n) for n in chr(valid_period)]) #UDL + UD message_pdu = "" if text_format == SEVENBIT_FORMAT : if len(text) <= 160 : print "GSM0338 (len %s)" % len(text) message_pdu = [self.__pack_8bits_to_7bits(text)] else: print "GSM0338 (len %s multipart)" % len(text) message_pdu = self.__split_sms_message(text, encoding=SEVENBIT_FORMAT, limit=160) else: if len(text) <= 70 : print "UNICODE (len %s)" % len(text) message_pdu = [self.__pack_8bits_to_ucs2(text)] else: print "UNICODE (len %s)" % len(text) message_pdu = self.__split_sms_message(text, encoding=UNICODE_FORMAT, limit=70) ret_msgs_list = [] for msg in message_pdu : ret_msgs_list.append(data_coding_scheme_pdu + valid_period_pdu + msg) return ret_msgs_list