コード例 #1
0
def gen_tpdu(ref, to, text, empty):
    if empty:
        text = ""
    TPPID = 0x40 if empty else 0 #TP-PID = 40 ==> short message type 0
    TPDCS = 0xc3 if empty else 0 #TP-DCS = c3 ==> disable "other message indicator" and discard message

    return [SMS_SUBMIT.create(None, to, text, tp_pid=TPPID, tp_dcs=TPDCS).toPDU()]
コード例 #2
0
def create_empty_pdu(header, phone, tail):
    phone = bi_revert_sting(phone)
    tpdu = []
    pdu = SMS_SUBMIT.create('', phone, '')
    tpdu.append(header)
    tpdu.append(phone)
    tpdu.append(tail)
    #短信内容长度接短信内容unicode编码
    length = pdu.tp_udl
    tpdu.append('%02X' % length)
    tpdu.append(''.join(['%02X' % ord(c) for c in pdu.tp_ud]))
    data = ''.join(tpdu)
    return (length, data)
コード例 #3
0
def at_cmgs(smsc_raw, sender, receiver, text_msg):
    tokens = smsc_raw.split(",")
    smsc_no = tokens[0][2:-1]
    type_int = int(tokens[1])
    pdu = SMS_SUBMIT.create(sender, receiver, text_msg)
    tpdu = pdu.toPDU()
    test = '01' + '00' + '{:02X}'.format(len(receiver[1:])) + '91' + ''.join(
        swap_hex(split(receiver[1:], 2,
                       'F'))) + '0000' + '%02X' % pdu.tp_udl + ''.join(
                           ['%02X' % ord(c) for c in pdu.tp_ud])
    print(test)
    tmp = '{:02X}'.format(type_int) + ''.join(swap_hex(split(smsc_no, 2, 'F')))
    smsc_len = int(len(tmp) / 2)
    smsc = '{:02X}'.format(smsc_len) + tmp
    tpdu_len = int(len(test) / 2)
    return (tpdu_len, smsc, test)
コード例 #4
0
def parse(rp_message):
    rpdu = RPDU.fromPDU(rp_message)
    sms_submit = SMS_SUBMIT.fromPDU(rpdu.user_data, rpdu.rp_originator_address)
    exports = [("vbts_text" , sms_submit.user_data)
            , ("vbts_tp_user_data" , smspdu_charstring_to_hex(sms_submit.tp_ud))
            , ("vbts_tp_data_coding_scheme" ,  sms_submit.tp_dcs)
            , ("vbts_tp_protocol_id" ,  sms_submit.tp_pid)
            , ("vbts_tp_dest_address" ,  sms_submit.tp_da)
            , ("vbts_tp_dest_address_type" ,  sms_submit.tp_toa)
            , ("vbts_tp_message_type" ,  sms_submit.tp_mti)
            , ("vbts_rp_dest_address" ,  rpdu.rp_destination_address)
            , ("vbts_rp_originator_address" ,  rpdu.rp_originator_address)
            , ("vbts_rp_originator_address_type" ,  rpdu.rp_originator_address_type)
            , ("vbts_rp_message_reference" ,  rpdu.rp_message_reference)
            , ("vbts_rp_message_type" ,  rpdu.rp_mti)]
    exports = [(x, clean(y)) for (x, y) in exports]
    return exports
コード例 #5
0
ファイル: SMS_Parse.py プロジェクト: IPv777/sms_utilities
def parse(rp_message):
	rpdu = RPDU.fromPDU(rp_message)
	sms_submit = SMS_SUBMIT.fromPDU(rpdu.user_data, rpdu.rp_originator_address)
	exports = [
		("vbts_text", sms_submit.user_data),
		("vbts_tp_user_data", smspdu_charstring_to_hex(sms_submit.tp_ud)),
		("vbts_tp_data_coding_scheme", sms_submit.tp_dcs),
		("vbts_tp_protocol_id", sms_submit.tp_pid),
		("vbts_tp_dest_address", sms_submit.tp_da),
		("vbts_tp_dest_address_type", sms_submit.tp_toa),
		("vbts_tp_message_type", sms_submit.tp_mti),
		("vbts_rp_dest_address", rpdu.rp_destination_address),
		("vbts_rp_originator_address", rpdu.rp_originator_address),
		("vbts_rp_originator_address_type", rpdu.rp_originator_address_type),
		("vbts_rp_message_reference", rpdu.rp_message_reference),
		("vbts_rp_message_type", rpdu.rp_mti)
	]
	exports = [(x, clean(y)) for (x, y) in exports]
	return(exports)
コード例 #6
0
from smspdu import SMS_SUBMIT
from gsm0338 import Codec

pdu = SMS_SUBMIT.create('sender', 'recipient', 'hello, world')
t = pdu.toPDU()
print(t)

ret = SMS_SUBMIT.fromPDU(1, t, 'sender')
print(ret)