def sendSms(message): r, d = gsm.sendAT("AT+CMGS=" + message.getNumber(), ">", 5) if(r == 0): r, d = gsm.sendAT(message.getText() + chr(0x1A), "OK", 10) if(r == 0): return 0 return -1
def sendSms(message): r, d = gsm.sendAT("AT+CMGS=" + message.getNumber(), ">", 5) if (r == 0): r, d = gsm.sendAT(message.getText() + chr(0x1A), "OK", 10) if (r == 0): return 0 return -1
def receiveSms(): r, d = gsm.sendAT("AT+CMGL=ALL", "OK", 5) if(r == 0): position = d.find('+CMGL') if(position != -1): d = d[position:] one = d.split('\r') if(len(one) > 1): header = one[0].strip()[7:] data = one[1].strip() header_data = header.split(',') if(len(header_data) > 5): index = header_data[0] status = header_data[1].replace('"', '') number = header_data[2].replace('"', '') time = header_data[4].replace('"', '') + ',' + header_data[5].replace('"', '') sms = sms_msg.SmsMessage(index, number, time, data) return sms return None
def receiveSms(): r, d = gsm.sendAT("AT+CMGL=ALL", "OK", 5) if (r == 0): position = d.find('+CMGL') if (position != -1): d = d[position:] one = d.split('\r') if (len(one) > 1): header = one[0].strip()[7:] data = one[1].strip() header_data = header.split(',') if (len(header_data) > 5): index = header_data[0] status = header_data[1].replace('"', '') number = header_data[2].replace('"', '') time = header_data[4].replace( '"', '') + ',' + header_data[5].replace('"', '') sms = sms_msg.SmsMessage(index, number, time, data) return sms return None
def deleteSms(index): r, d = gsm.sendAT("AT+CMGD=" + index, "OK", 5) if (r == 0): return 0 return -1
def init(): gsm.sendAT('AT#SMSMODE=1', 'OK') gsm.sendAT('AT+CMGF=1', 'OK')
def resetWatchdog(): gsm.sendAT("AT#ENHRST=1,10", "OK", 5)
def deleteSms(index): r, d = gsm.sendAT("AT+CMGD=" + index, "OK", 5) if(r == 0): return 0 return -1
def resetWatchdog(): gsm.sendAT("AT#ENHRST=1,10", "OK", 5) SER2.send('OK\r\n')