A C# wrapper for the JLR InControl remote connectivity. You need a Jaguar Remote account with a valid subscription.
Connecting can be done using username and password, or by caching off the respective OAuth tokens and using them for the next connection.
// Connect to the Jaguar Remote service with your credentials
JlrSharpConnection jlrSharp = new JlrSharpConnection("[email protected]", "your_password");
// Make the first connection as normal
JlrSharpConnection jlrSharp = new JlrSharpConnection("[email protected]", "your_password");
// Now, cache the credentials
AuthorisedUser credentials = jlrSharp.GetAuthorisedUser();
// The next connection
JlrSharpConnection jlrSharpNew = new JlrSharpConnection(credentials.UserInfo, credentials.TokenData);
If you've databased the connection details, you can recreate them as such and then pass them to the last constructor in the above example. This also describes the minimum data that you are required to store.
// Create the credential objects
UserDetails userDetails = new UserDetails
{
DeviceId = Guid.Parse(guid),
DeviceIdExpiry = DateTime.Now.AddHours(24),
Email = emailAddress,
UserId = userId,
};
TokenStore tokenStore = new TokenStore
{
access_token = accessToken,
CreatedDate = DateTime.Now,
};
If you plan to use the library in a service, you may wish to use the automatic token refresh
JlrSharpConnection jlrSharp = new JlrSharpConnection("[email protected]", "your_password");
jlrSharp.AutoRefreshTokens = true;
GetPrimaryVehicle() will return the first car linked on the InControl app.
// Returns the primary vehicle, as a generic vehicle
Vehicle vehicle = jlrSharp.GetPrimaryVehicle();
By converting to a more specific type will open vehicle specific actions. Some functionality is provided by the base class, such as GetMileage()
if (vehicle is ElectricVehicle electricVehicle)
{
...
}
else if (vehicle is GasVehicle gasVehicle)
{
...
}
vehicle.GetMileage(); // Returns the odometer reading in miles
vehicle.GetServiceDueInMiles(); // Returns the miles until next service
vehicle.IsLocked(); // Determines if the vehicle is locked
The following functions require the pin code
vehicle.Lock("1234");
vehicle.Unlock("1234");
vehicle.HonkAndBlink("1234");
vehicle.GetDistanceUntilEmpty(); // Returns the remaining range until empty
vehicle.GetFuelLevelPercentage(); // Returns the remaining fuel level as a percentage
vehicle.StartEngine(string pin);
vehicle.StopEngine(string pin);
vehicle.IsPluggedIn(); // Determines if the vehicle is plugged in
vehicle.IsCharging(); // Determines if the vehicle is charging
vehicle.StartCharging(string pin); // Instructs the car to start charging
vehicle.StopCharging(string pin); // Instructs the car to stop charging
vehicle.StartClimatePreconditioning(string pin, string targetTemp); // Instructs the vehicle to start pre-conditioning the vehicle
vehicle.StopClimatePreconditioning(string pin); // Instructs the vehicle to start pre-conditioning the vehicle