def getmsg(self, index): cmd = 'AT+CMGR=' + index + '\r\n' self.com.write(cmd.encode()) res = self.waitfor() res = res[3:-1] str = '\n'.join(res) demsg = decodepdu(str) demsg = '\n'.join(demsg) f = open("msg.txt", 'a') f.write('\r\n\r\n') f.write(demsg) f.write('\r\n\r\n') f.close() print('str is %s,res:%s' % (str, res)) self.delmsg(index) return demsg
def msginit(): if handle.isconnect(): print('A6 is lost...exit()') return 1 if handle.setpdumode() == 'ERR': return 'ERR' pudmsg = handle.listmsg_unread() sendmail = '' if len(pudmsg) == 0: log("no msg to read") else: for i in range(0, len(pudmsg)): str = decodepdu(pudmsg[i]) sendmail += '\n'.join(str) if pingdemo.Netchk(): logmsg_unmail(sendmail) else: mail(sendmail)