Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
def deleteSms(index):
    r, d = gsm.sendAT("AT+CMGD=" + index, "OK", 5)
    if (r == 0):
        return 0
    return -1
Example #6
0
def init():
    gsm.sendAT('AT#SMSMODE=1', 'OK')
    gsm.sendAT('AT+CMGF=1', 'OK')
Example #7
0
def resetWatchdog():
    gsm.sendAT("AT#ENHRST=1,10", "OK", 5)
Example #8
0
def deleteSms(index):
    r, d = gsm.sendAT("AT+CMGD=" + index, "OK", 5)
    if(r == 0):
        return 0
    return -1
Example #9
0
def init():
    gsm.sendAT('AT#SMSMODE=1', 'OK')
    gsm.sendAT('AT+CMGF=1', 'OK')
Example #10
0
def resetWatchdog():
    gsm.sendAT("AT#ENHRST=1,10", "OK", 5)
    SER2.send('OK\r\n')