def send_data(): reader.read_once() HTTPRequest.send(reader.getAndClear()) board.blink("blue")
"ultrasonic-ranger": config.getint('sensors', 'ultrasonic-ranger'), "dht": config.getint('sensors', 'temp-sensor') }, "buttons": { "reset-wifi": config.getint('buttons', 'reset-wifi') } } # The maximum buffer size to hold before culling records. GLOBALS['maxBuffer'] = config.get('misc', 'max-buffer-size') # The number of errors that need to occur before the application slows post speed. GLOBALS['maxErrorCount'] = config.get('misc', 'error-count') # Initialize the HTTPRequest object with the API Key and Content Type. HTTPRequest.init(config.get('api', 'key'), config.get('api', 'content-type'), config.get('api', 'endpoint') + GATEWAY_ID + "/data") # TODO(Sunil): Add more fine grained error counters # TODO(Sunil): Stop using any global variables # Shutdown the IOLoop cleanly def sig_handler(sig, frame): tornado.ioloop.IOLoop.instance().add_callback(shutdown) def shutdown(): MAX_WAIT_SECONDS_BEFORE_SHUTDOWN = 20 io_loop = tornado.ioloop.IOLoop.instance() deadline = time.time() + MAX_WAIT_SECONDS_BEFORE_SHUTDOWN
"flow-sensor": config.getint('sensors', 'flow-sensor'), "ultrasonic-ranger": config.getint('sensors', 'ultrasonic-ranger'), "dht": config.getint('sensors', 'temp-sensor') }, "buttons": { "reset-wifi": config.getint('buttons', 'reset-wifi') }} # The maximum buffer size to hold before culling records. GLOBALS['maxBuffer'] = config.get('misc', 'max-buffer-size') # The number of errors that need to occur before the application slows post speed. GLOBALS['maxErrorCount'] = config.get('misc', 'error-count') # Initialize the HTTPRequest object with the API Key and Content Type. HTTPRequest.init(config.get('api', 'key'), config.get('api', 'content-type'), config.get('api', 'endpoint') + GATEWAY_ID + "/data") # TODO(Sunil): Add more fine grained error counters # TODO(Sunil): Stop using any global variables # Shutdown the IOLoop cleanly def sig_handler(sig, frame): tornado.ioloop.IOLoop.instance().add_callback(shutdown) def shutdown(): MAX_WAIT_SECONDS_BEFORE_SHUTDOWN = 20 io_loop = tornado.ioloop.IOLoop.instance() deadline = time.time() + MAX_WAIT_SECONDS_BEFORE_SHUTDOWN def stop_loop(): now = time.time() if now < deadline and (io_loop._callbacks or io_loop._timeouts):
def send_data(): reader.read_once() HTTPRequest.send(reader.getAndClear())