Ejemplo n.º 1
0
Archivo: sms.py Proyecto: 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' )
Ejemplo n.º 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')
Ejemplo n.º 3
0
Archivo: sms.py Proyecto: 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 )
Ejemplo n.º 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)
Ejemplo n.º 5
0
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])
Ejemplo n.º 6
0
Archivo: util.py Proyecto: 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])
Ejemplo n.º 7
0
Archivo: sms.py Proyecto: jgrahamc/gaga
def init():
    at.cmd( 'AT+CMGF=1' )
Ejemplo n.º 8
0
def init():
    at.cmd('AT+CMGF=1')