Пример #1
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' )
Пример #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
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
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
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
def init():
    at.cmd( 'AT+CMGF=1' )
Пример #8
0
def init():
    at.cmd('AT+CMGF=1')