def serialize(self): result = [] result.append(int2hexstr(len(self.number))) # GSM 03.40, section 9.1.2.5 header = 0x80 header = header | (self.type_of_number << 4) header = header | self.numbering_plan_id result.append(int2hexstr(header)) result.append(swap(self.number)) return "".join(result)
def serialize(self): if self.type_of_number == ALPHANUMERIC: print "Don't know how to serialize an alphanumeric SMS yet" return "" result = [] result.append(int2hexstr(len(self.number))) # GSM 03.40, section 9.1.2.5 header = 0x80 header = header | (self.type_of_number << 4) header = header | self.numbering_plan_id result.append(int2hexstr(header)) result.append(swap(self.number)) return "".join(result)
def get_pdu(self): """Returns the PDU of the message""" pdu = [] assert self.smsc.startswith('+') swapped_smsc = swap(self.smsc[1:]) swapped_smsc = '91' + swapped_smsc pdu.append(int2hexstr(self.get_smsc_len())) pdu.append(swapped_smsc) # TP-Message-Type-Indicator = 01 # header = header | 0x01 # TP-Reject-Duplicates = 0 # TP-Validity-Period-Format = 00 (TP-VP field not present) # TP-Status-Report-Request = 0 # TP-User-Data-Header-Indicator # TP-Reply-Path = 0 #pdu.append(int2hexstr(header)) pdu.append(int2hexstr(17)) # TP-Message-Reference = 0 pdu.append(int2hexstr(0)) # TP-Destination-Address pdu.append(self.address.serialize()) # TP-Protocol-Identifier pdu.append(int2hexstr(0)) # TP-Data-Coding-Scheme dcs = 0 if self.encoding == DEFAULT_ALPHABET: dcs = dcs | 0x00 else: dcs = dcs | 0x08 pdu.append(int2hexstr(dcs)) # TP-Validity-Period pdu.append(int2hexstr(self.validity)) # TP-User-Data-Length pdu.append(int2hexstr(self.user_data_length)) # TP-User-Data pdu.append(self.user_data) return "".join(pdu)