예제 #1
0
파일: sms.py 프로젝트: jgrahamc/gaga
def send(phone, text):
    logger.log( 'sms.send(%s...,"%s")' % ( phone[0:4], text ) )
    if can():
        r = at.cmd( 'AT+CMGS="%s"' % phone )
        if r == '\r\n> ':
            t = util.timestamp()
            r = at.raw( '%s: %s\x1A' % ( t, text ), 30 )
        else:
            r = at.raw( '\x1B' )
            logger.log( 'Failed to get SMS prompt' )
    else:
        logger.log( 'No GSM access for SMS send' )
예제 #2
0
def send(phone, text):
    logger.log('sms.send(%s...,"%s")' % (phone[0:4], text))
    if can():
        r = at.cmd('AT+CMGS="%s"' % phone)
        if r == '\r\n> ':
            t = util.timestamp()
            r = at.raw('%s: %s\x1A' % (t, text), 30)
        else:
            r = at.raw('\x1B')
            logger.log('Failed to get SMS prompt')
    else:
        logger.log('No GSM access for SMS send')
예제 #3
0
파일: sms.py 프로젝트: jgrahamc/gaga
def can():
    r = at.cmd( 'AT+CSQ' )

    # Comman returns something like
    #
    # +CSQ: 9,0
    #
    # So first split on whitespace, then on the :

    w = r.split()
    if len(w) < 2:
        return 0

    m = w[1].split(',')
    if len(m) != 2:
        return 0
    else:
        return ( int(m[0]) != 99 ) and ( int(m[1]) != 99 )
예제 #4
0
def can():
    r = at.cmd('AT+CSQ')

    # Comman returns something like
    #
    # +CSQ: 9,0
    #
    # So first split on whitespace, then on the :

    w = r.split()
    if len(w) < 2:
        return 0

    m = w[1].split(',')
    if len(m) != 2:
        return 0
    else:
        return (int(m[0]) != 99) and (int(m[1]) != 99)
예제 #5
0
파일: util.py 프로젝트: jgrahamc/gaga
def temperature():
    t = at.cmd( 'AT#TEMPMON=1' )

    # Command returns something like:
    #
    # #TEMPMEAS: 0,28
    #
    # OK
    #
    # So split on whitespace first to isolate the temperate 0,28 and
    # then split on comma to get the temperature

    w = t.split()
    if len(w) < 2:
        logger.log( "Temperature read returned %s" % t )
        return -1000
  
    m = w[1].split(',')
    if len(m) != 2:
        logger.log( "Temperature read returned %s" % t )
        return -1000
    else:
        return int(m[1])
예제 #6
0
파일: util.py 프로젝트: wal99d/gaga
def temperature():
    t = at.cmd('AT#TEMPMON=1')

    # Command returns something like:
    #
    # #TEMPMEAS: 0,28
    #
    # OK
    #
    # So split on whitespace first to isolate the temperate 0,28 and
    # then split on comma to get the temperature

    w = t.split()
    if len(w) < 2:
        logger.log("Temperature read returned %s" % t)
        return -1000

    m = w[1].split(',')
    if len(m) != 2:
        logger.log("Temperature read returned %s" % t)
        return -1000
    else:
        return int(m[1])
예제 #7
0
파일: sms.py 프로젝트: jgrahamc/gaga
def init():
    at.cmd( 'AT+CMGF=1' )
예제 #8
0
def init():
    at.cmd('AT+CMGF=1')