Pit-side client software to allow the user to navigate though historical and real time telemetry data from the car. Maintains an internal buffer of recent data and archives to Firebase Cloud Firestore. Developed using Flask and designed to be deployed to Google Cloud App Engine.
Automated build deployment is enabled for the master branch, so pushing to master deploys the code to production. Exception: If the oursecrets folder is changed you have to run local deployment to see those changes on the server. Follow the instructions below to push from your local.
The root folder needs to have ourSecrets/__init__.py, ourSecrets/keys.py, ourSecrets/ku-solar-car-b87af-eccda8dd87e0.json, and ourSecrets/ku-solar-car-b87af-firebase-adminsdk-ttwuy-0945c0ac44.json
files with the necessary contents. You can download them from Slack.
Link to Medium article on deploying
Setup GCloud Terminal (click "Install and Initialize the Cloud SDK" to download)
Make sure you are in the TelemetryServer repository in your terminal before continuing
- Once you get GCloud setup on your terminal, make sure you have the correct project by default:
gcloud config set project ku-solar-car-b87af
- Make sure your app.yaml file is correct:
runtime: python37
entrypoint: gunicorn -b :8080 main:app- Run the following command to deploy. This takes a few minutes.
gcloud app deploy
Publishes the application the URL (gcloud app browse): https://ku-solar-car-b87af.appspot.com
- Post To Server (endpoint is
/car)
Data will come from TelemetrySource. To send test the server, make a POST request with the body in the following format:
{
"battery_voltage": 400,
"battery_current": 400,
"battery_temperature": 400,
"bms_fault": 1,
"gps_time": 400,
"gps_lat": 400,
"gps_lon": 400,
"gps_speed": 400,
"solar_voltage": 400,
"solar_current": 400,
"motor_speed": 400
}
Deploying to Google Cloud creates [an absured amount of] temporary files in the Google Cloud Storage bucket us.artifacts.ku-solar-car-b87af.appspot.com. These can be deleted from Google Cloud Console and set up to automatically expire to avoid going over the free tier storage limit (1 GB).
The application can be run on a development machine by running app.py with Python 3. In the Google Cloud Console, the Logs Explorer allows you to view console output, including exceptions, similar to running what you get running the application locally.