On 22Sep2015 04:19, Timon Rhynix <timgeek...@gmail.com> 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

Two suggestions:

 as already suggested, you may need to send \r\n instead of just \r

do you need to follow every .write() with a .flush()? if the Serial object is a buffered stream that will be necessary

Cheers,
Cameron Simpson <c...@zip.com.au>

Motorcycling is indeed a delightful pastime.    - Honda Rider Training Film
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to