I am beginner in python,But here is issue that when we send sms language unicode(Hindi, Arabic...etc ), but sms not sent .What can i do please help me. If you have any idea then give me suggestion that how cans send multi language sms send using modem or dongle.
def recept(message, recipient):
time.sleep(0.5)
phone.write('AT\r\n')
time.sleep(0.5)
phone.write('AT+CMGF=1\r\n')
time.sleep(0.5)
phone.write('AT+CMGW="'+recipient+'"\r\n')
out = ''
time.sleep(1)
while phone.inWaiting() > 0:
out += phone.read(1)
if out != '':
print ">>" + out
phone.write(message)
phone.write('\x1a')
out = ''
time.sleep(1)
while phone.inWaiting() > 0:
out += phone.read(1)
if out != '':
print ">>" + out
number = get_num(out)
phone.write('AT+CMSS='+number+'\r\n')
out = ''
time.sleep(1)
while phone.inWaiting() > 0:
out += phone.read(1)
if out != '':
print ">>" + out
def sendSMS(message):
try:
phone.open()
phone.flushInput()
phone.flushOutput()
for row in mobileno:
time.sleep(0.5)
mobile = row
recept(message, mobile)
time.sleep(1)
phone.write('AT+CMGD=1,4\r\n')
phone.close()
finally:
phone.close()
# type your message here
message = u'लड़की के चक्कर में मत पड़ना भाई'
sendSMS(message)
+++++++++++++++++ ERROR ++++++++++++++++++++++
लड़की के चक्कर में मत पड़ना भाई
>>AT
OK
AT+CMGF=1
OK
AT+CMGW="Phone number with country code"
>
Traceback (most recent call last):
File "right.py", line 76, in <module>
sendSMS(message)
File "right.py", line 65, in sendSMS
recept(u'लड़की के चक्कर में मत पड़ना भाई', mobile)
File "right.py", line 40, in recept
phone.write(u'लड़की के चक्कर में मत पड़ना भाई')
File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 491, in write
d = to_bytes(data)
File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 76, in to_bytes
b.append(item) # this one handles int and str for our emulation and ints for Python 3.x
TypeError: an integer or string of size 1 is required
Thanks in advance