Exemplo n.º 1
0
config = configparser.ConfigParser()
config.read(OBD2HOME + '/gateway.ini')

carID = config['DEFAULT']['carID']

# should be read from config file
HOST = "ubuntucontainers-dashboariotnew-zekci6cs.srv.ravcloud.com"
PORT = 8883

# clientID is passed to make possible different clientID
# MQTT doesn't allow different clients with same ID (second is disconnected)
gateway = Device("googshut1")

# try connecting in loop
# to handle case in which initially no network connection
while gateway.isConnected() != True:
    try:
        gateway.connect(HOST, PORT, "YES")
    except:
        print('*** Error in MQTT connection !')
        print('\n')
        print('*** Error info: ', sys.exc_info()[0], sys.exc_info()[1])

    time.sleep(sleepTime)

button = aiy.voicehat.get_button()
button.on_press(on_button_press)

while True:
    print('Another loop...')
    time.sleep(5)