Successfully send sms with python

Timon Rhynix timgeek951 at gmail.com
Tue Sep 22 13:19:49 CEST 2015


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


More information about the Python-list mailing list