app

Rovercode app.

Functions

MotorManager(\*args, \*\*kwargs)
connect() Connect to the rovercode-web websocket.
display_home_message() Display a message if someone points a browser at the root.
emit(event, \*args, \*\*kwargs) Emit a SocketIO event.
find_dotenv([filename, ...]) Search in increasingly higher folders for the given file
get_local_ip() Get the local area network IP address of the rover.
init_input_gpio(left_eye_pin, right_eye_pin) Initialize input GPIO.
jsonify(\*args, \*\*kwargs) This function wraps dumps() to add a few enhancements that make life easier.
load_dotenv(dotenv_path[, verbose, override]) Read a .env file and load into os.environ.
run_command(decoded) Run the command specified by decoded.
send_command() API: /sendcommand [POST].
sensors_thread() Scan each binary sensor and sends events based on changes.
set_rovercodeweb_url(base_url) Set the global URL variables for rovercodeweb.
singleton(class_) Helper class for creating a singleton.
test_message(message) Send a debug test message when status is received from rovercode-web.

Classes

BinarySensor(name, pin, rising_event, ...) The binary sensor object contains information for each binary sensor.
CORS([app]) Initializes Cross Origin Resource sharing for the application.
Flask(import_name[, static_path, ...]) The flask object implements a WSGI application and acts as the central object.
HeartBeatManager(client_id, client_secret[, id]) A manager to register the rover with rovercode-web and periodically check in.
SocketIO([app]) Create a Flask-SocketIO server.
class app.BinarySensor(name, pin, rising_event, falling_event)

The binary sensor object contains information for each binary sensor.

Parameters:
  • name – The human readable name of the sensor
  • pin – The hardware pin connected to the sensor
  • rising_event – The event name associated with a signal changing from low to high
  • falling_event – The event name associated with a signal changing from high to low

Constructor for BinarySensor object.

class app.HeartBeatManager(client_id, client_secret, id=None)

A manager to register the rover with rovercode-web and periodically check in.

Parameters:
  • client_id – The Oauth2 client id for this rover.
  • client_secret – The Oauth2 client secret for this rover.

Constructor for the HeartBeatManager.

read()

Look for our name on rovercode-web. Sets web_id if found.

stopThread()

Gracefully stop the periodic check-in thread.

thread_func(run_once=False)

Thread function that periodically checks in with rovercode-web.

update()

Check in with rovercode-web, updating our timestamp.

app.connect()

Connect to the rovercode-web websocket.

app.display_home_message()

Display a message if someone points a browser at the root.

app.get_local_ip()

Get the local area network IP address of the rover.

app.init_input_gpio(left_eye_pin, right_eye_pin)

Initialize input GPIO.

app.run_command(decoded)

Run the command specified by decoded.

Parameters:decoded – The command to run
app.send_command()

API: /sendcommand [POST].

Executes the posted command

Available Commands:::
START_MOTOR STOP_MOTOR
app.sensors_thread()

Scan each binary sensor and sends events based on changes.

app.set_rovercodeweb_url(base_url)

Set the global URL variables for rovercodeweb.

app.singleton(class_)

Helper class for creating a singleton.

app.test_message(message)

Send a debug test message when status is received from rovercode-web.