import MOD
import MDM
import debug
 
#SMS Send
def sms_send(to, text):
    global status1
    debug.msg('Send SMS to: %s, MSG: %s' % (to, text))
 
    MDM.send('AT+CMGS="' + to + '"\r', 0)
    res = MDM.receive(50)#5 sec
    MOD.sleep(1)#wait 0.1sec
 
    #Check for SMS prompt
    if (res == '\r\n> '):
 
        #Send SMS message text
        MDM.send(text, 0)
 
        #End SMS
        MDM.sendbyte(0x1A, 0)
        res2 = MDM.receive(180)#5 sec
        MOD.sleep(1)#wait 0.1sec
 
        if (res2.find('\r\nOK\r\n') != -1):
            debug.msg('SMS sent')
            status1 = TRUE
        else:
            debug.msg('SMS Send: ' + res2)
            debug.msg('Did not get SMS sent confirmation')
            status1 = FALSE
    else:
        debug.msg('SMS Send: ' + res)
        debug.msg('Did not receive SMS prompt')
 
        #Abort SMS (just in case)
        MDM.sendbyte(0x1B, 0)
        MOD.sleep(1)#wait 0.1sec
        status1 = FALSE
 
        return status1
 
#Setup SMS
def sms_setup():
    MDM.send('AT+CMGF=1\r', 0)
    res = MDM.receive(50)#5 sec
    MOD.sleep(1)#wait 0.1sec
 
#Check GSM Reception
def reception_check():
    MDM.send('AT+CSQ\r', 0)
    res = MDM.receive(10)#1sec
    rec_parts = res.split('\r\n')
    rec_parts2 = rec_parts[1].split(':')
    debug.msg('Reception: ' + rec_parts2[1])
    return rec_parts2[1]
 
projects/firefly/smslib.py.txt · Last modified: 2008/04/18 23:56 by jamescoxon
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki