pmarti/python-messaging

sms.cnt and sms.seq

multijohn opened this issue · 4 comments

Hi,

Giving sms.data i'm taking the results.
same with sms.text and sms.number
But sms.cnt or sms.seq gives error.
How can i put in variables the cnt and seq values?

Thank u!

Hi there,
If you have a multipart message, then the cnt, seq and ref values can be found as following:

sms = SmsDeliver(pdu)
cnt = sms.udh.concat.cnt
seq = sms.udh.concat.seq
ref = sms.udh.concat.ref

But note that they are only set if you have a pdu from a concatenated message, so you probably need to check that sms.udh.concat is not None

See 'test_decode_weird_multipart_german_pdu()' in messaging/test/test_sms.py for an example

Hi,
Is this acceptable?

`if 'cnt' in str(sms.data):
cnt = sms.udh.concat.cnt
seq = sms.udh.concat.seq
ref = sms.udh.concat.ref

else:
cnt = 0
seq = 0
ref = 0`

Thank's!

Not sure I like doing the string comparison, but it's probably a matter of taste. I think I'd do something like:

if sms.udh is not None and sms.udh.concat is not None:
    cnt = sms.udh.concat.cnt
    seq = sms.udh.concat.seq
    ref = sms.udh.concat.ref
else:
   cnt = seq = ref = 0

Hello Again,

Than u for your help !!