-
Notifications
You must be signed in to change notification settings - Fork 4
Server to Simulator Client API
The Simulator Client will provide an API for the server to push commands to. It will mirror the Vechicle Commands API provided for the Tesla.
Via Websockets - http://www.html5rocks.com/en/tutorials/websockets/basics/
Communication will be done using JSON
##Initialisation
Connection will be initiated from the client to the server with the Simulator "logging in" to the server for each vehicle it is simulating.
The client will connect to the server using a normal AJAX request, sending an email address provided for simulation. This will match the email used in the "credentials to access the Tesla API. We can extend this to require a password should it be necessary.
The server will manage vehicle id's for sessions on the simulator.
This vehicle ID will be sent by the server in future commands, enabling the client to simulate multiple vehicles.
{
"command": "login",
"params: {
"email_address": "testing@test.com"
}
}
{
"vehicle_id": "abc1234"
}
In future the client should be able to display multiple vehicles. We would need a method of "unauthenticated" login to be able to get a list of vehicle id's for display, example shown below.
{
"command": "list_vehicle_ids"
}
{
["abc1234", "def5678", "ace1357", "bdf2468" ]
}
##Responding to Commands
Each command from Server to Client will be sent as a JSON object, containing the vehicle ID, the command name and any parameters encapsulated as a sub-object.
JSON object keys and the command value will be underscored to match those used in the REST API.
The protocol may be extended in the future to allow arrays of commands to be sent at once.
The client will not "reply" to the server for each command.
{
"vehicle_id": "abc1234",
"command": "honk_horn"
}
{
"vehicle_id": "abc1234",
"command": "set_temps",
"params": {
"driver_temp": 23.7,
"passenger_temp": 18.0
}
}