Successfully send sms with python

Pavel S pavel at schon.cz
Tue Sep 22 08:16:28 EDT 2015


On Tuesday, September 22, 2015 at 1:20:07 PM UTC+2, Timon Rhynix wrote:
> Hello, I have used pyserial, sms0.4 and other libraries to send sms via huawei E1750 modem.
> The code runs well and no error is thrown but the text message is not sent/delivered to the number.
> One of my code is as follows:
> 
> import serial
> import time
> 
> class TextMessage:
>     def __init__(self, recipient="0123456789", message="TextMessage.content not set."):
>         self.recipient = recipient
>         self.content = message
> 
>     def setRecipient(self, number):
>         self.recipient = number
> 
>     def setContent(self, message):
>         self.content = message
> 
>     def connectPhone(self):
>         conn = 'COM13'
>         self.ser = serial.Serial(conn, 460800, timeout=5)
>         time.sleep(1)
> 
>     def sendMessage(self):
>         self.ser.write('ATZ\r')
>         time.sleep(1)
>         self.ser.write('AT+CMGF=1\r')
>         time.sleep(1)
>         self.ser.write('''AT+CMGS="''' + self.recipient + '''"\r''')
>         time.sleep(1)
>         self.ser.write(self.content + "\r")
>         time.sleep(1)
>         self.ser.write(chr(26))
>         time.sleep(1)
>         print "message sent!"
> 
>     def disconnectPhone(self):
>         self.ser.close()
> 
> When run it, the "message sent!" is printed but no message is sent/delivered.
> Please assist on what I am missing. Thank you

Hi,

why don't you use http://wammu.eu/python-gammu/
?



More information about the Python-list mailing list