Exemplo n.º 1
0
def run_hologram_receive_data(args):

    global hologram
    hologram = HologramCloud(dict(), network='cellular')

    hologram.event.subscribe('message.received', popReceivedMessage)

    if not hologram.network.at_sockets_available:
        hologram.network.connect()

    hologram.openReceiveSocket()
    print('Ready to receive data on port %s' % hologram.receive_port)

    try:
        handle_polling(args['timeout'], popReceivedMessage, 1)
    except KeyboardInterrupt as e:
        print 'Closing socket...'
        hologram.closeReceiveSocket()

        if not hologram.network.at_sockets_available:
            hologram.network.disconnect()

        sys.exit(e)

    if not hologram.network.at_sockets_available:
        hologram.network.disconnect()
Exemplo n.º 2
0
def run_hologram_receive_sms(args):
    global hologram
    hologram = HologramCloud(dict(), network='cellular')
    print('Ready to receive sms')
    try:
        handle_polling(args['timeout'], popReceivedSMS, 1)
    except KeyboardInterrupt as e:
        sys.exit(e)
def run_hologram_spacebridge(args):
    global hologram
    hologram = HologramCloud(dict(), network='cellular')

    hologram.event.subscribe('message.received', popReceivedMessage)

    hologram.network.disable_at_sockets_mode(
    )  # Persistent cellular connection
    hologram.network.scope = NetworkScope.HOLOGRAM  # Default route NOT set to cellular
    hologram.network.connect()

    hologram.openReceiveSocket()
    print('Ready to receive data on port %s' % hologram.receive_port)

    try:
        handle_polling(args['timeout'], popReceivedMessage, 1)
    except KeyboardInterrupt as e:
        print('Closing socket...')
        hologram.closeReceiveSocket()
        sys.exit(e)
    finally:
        hologram.network.disconnect()