Python UCP Library

-- mode: rst --

https://launchpad.net/ucplib

EMI - UCP interface specification v4.6 with ucplib

Setup

First we need to import the UcpMsg form the library >>> from ucplib import UcpMsg

General examples

The SMT sends a message to the SMSC with text "hello" in the GSM 7-bit alphabet. Note that “hello” in ASCII has the same encoding.

'49/00078/O/51/0031612345678/55555/////////////////3//68656C6C6F/////////////0D'

Specific types

Type 01 messages
Operation

Alphanumeric message 'Short Message' to receiver 01234567890 from sender 09876543210

>>> msg = UcpMsg( o_r="O", ot=01, adc="01234567890", oadc="09876543210", mt=3, amsg=u"Short Message") >>> print msg 00/00070/O/01/01234567890/09876543210//3/53686F7274204D657373616765/D9

Now let's try to parse the message and see if wo obtain the same result

>>> print UcpMsg('x0200/00070/O/01/01234567890/09876543210//3/53686F7274204D657373616765/D9x03') 00/00070/O/01/01234567890/09876543210//3/53686F7274204D657373616765/D9

Now we create a numeric message '716436383334'

>>> print UcpMsg(o_r="O", ot=01, adc="0888444", mt=2, nmsg="716436383334") 00/00041/O/01/0888444///2/716436383334/C5

>>> print UcpMsg('x0200/00041/O/01/0888444///2/716436383334/C5x03') 00/00041/O/01/0888444///2/716436383334/C5

Response

Positive Result

>>> print UcpMsg(o_r="R", ot=01, trn=6, ack="A", sm="01234567890:090196103258") 06/00043/R/01/A/01234567890:090196103258/4E

>>> print UcpMsg('x0206/00043/R/01/A/01234567890:090196103258/4Ex03') 06/00043/R/01/A/01234567890:090196103258/4E

Negative Result

>>> print UcpMsg(o_r="R", ot=01, trn=12, nack="N", ec=2) 12/00022/R/01/N/02//03

>>> print UcpMsg('x0212/00022/R/01/N/02//03x03') 12/00022/R/01/N/02//03

Type 02 messages
Operation

Alphanumeric message ‘SMSC’ to 3 subscribers

>>> print UcpMsg(o_r="O", ot=02, trn=5, npl="3", rads=["01111","02222","03333"], oadc="0123456789", mt="3", amsg="SMSC") 05/00059/O/02/3/01111/02222/03333/0123456789//3/534D5343/52

>>> print UcpMsg('x0205/00059/O/02/3/01111/02222/03333/0123456789//3/534D5343/52x03') 05/00059/O/02/3/01111/02222/03333/0123456789//3/534D5343/52

Numeric message ‘563444' to 5 subscribers

>>> print UcpMsg(o_r="O", ot=02, trn=17, npl=5, rads=["01111","02222","03333","04444","05555"], oadc="0123456789", mt=2, nmsg="563444") 17/00069/O/02/5/01111/02222/03333/04444/05555/0123456789//2/563444/44

>>> print UcpMsg('x0217/00069/O/02/5/01111/02222/03333/04444/05555/0123456789//2/563444/44x03') 17/00069/O/02/5/01111/02222/03333/04444/05555/0123456789//2/563444/44

Response

Positive Result

>>> print UcpMsg(o_r="R", ot=02, trn=82, ack="A", sm="0654321:090196113940,065432:090196113940") 82/00059/R/02/A/0654321:090196113940,065432:090196113940/86

>>> print UcpMsg('x0282/00059/R/02/A/0654321:090196113940,065432:090196113940/86x03') 82/00059/R/02/A/0654321:090196113940,065432:090196113940/86

Negative Result

>>> print UcpMsg(o_r="R", ot=02, trn=47, nack="N", ec="01") 47/00022/R/02/N/01//0B

>>> print UcpMsg('x0247/00022/R/02/N/01//0Bx03') 47/00022/R/02/N/01//0B

Type 51 messages
Operation

Alphanumeric message ‘Message 51' with validity period set and with notification request to a PC application over TCP/IP.

>>> print UcpMsg(o_r="O", ot=51, trn=18, adc="012345", oadc="09876", nrq="1", nadc="1920870340125000", nt="4", npid="0539", vp="3012961212", mt="3", amsg="Message 51") 18/00113/O/51/012345/09876//1/1920870340125000/4/0539//////3012961212//////3//4D657373616765203531/////////////CD

>>> print UcpMsg("x0218/00113/O/51/012345/09876//1/1920870340125000/4/0539//////3012961212//////3//4D657373616765203531/////////////CDx03") 18/00113/O/51/012345/09876//1/1920870340125000/4/0539//////3012961212//////3//4D657373616765203531/////////////CD

TD message with deferred delivery set and notification request within the session for all types of notification

>>> print UcpMsg(o_r="O", ot=51, trn=39, adc="0657467", oadc="078769", nrq="1", nt="7", lrq="1", lrad="0545765", lpid="0122", dd="1", ddt="0808971800", mt="4", tmsg="F5AA34DE", mcls="1") 39/00099/O/51/0657467/078769//1//7//1/0545765/0122/1/0808971800///////4/32/F5AA34DE////1/////////65

>>> print UcpMsg("x0239/00099/O/51/0657467/078769//1//7//1/0545765/0122/1/0808971800///////4/32/F5AA34DE////1/////////65x03") 39/00099/O/51/0657467/078769//1//7//1/0545765/0122/1/0808971800///////4/32/F5AA34DE////1/////////65

Response

Positive Result

>>> print UcpMsg(o_r="R", ot=51, trn=0, ack="A", sm="012234:090996101010") 00/00039/R/51/A//012234:090996101010/68

>>> print UcpMsg("x0200/00039/R/51/A//012234:090996101010/68x03") 00/00039/R/51/A//012234:090996101010/68

Negative Result

>>> print UcpMsg(o_r="R", ot=51, nack="N", ec="31") 00/00022/R/51/N/31//07

>>> print UcpMsg("x0200/00022/R/51/N/31//07x03") 00/00022/R/51/N/31//07