mirror of
https://github.com/q39JzrRa/GM-Vehicle-API.git
synced 2025-12-23 23:38:45 -05:00
Implemented location and tbt commands. Fixed broken build.
This commit is contained in:
@@ -414,11 +414,11 @@ namespace GM.Api
|
||||
}
|
||||
|
||||
|
||||
JObject reqObj = new JObject();
|
||||
JObject reqObj = requestParameters;
|
||||
|
||||
if (requestParameters != null)
|
||||
if (reqObj == null)
|
||||
{
|
||||
reqObj[$"{command}Request"] = requestParameters;
|
||||
reqObj = new JObject();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,15 +60,49 @@ namespace GM.Api
|
||||
/// <returns>True or false for success</returns>
|
||||
public async Task<bool> LockDoor()
|
||||
{
|
||||
|
||||
var reqObj = new JObject()
|
||||
{
|
||||
["delay"] = 0
|
||||
["lockDoorRequest"] = new JObject()
|
||||
{
|
||||
["delay"] = 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return await InitiateCommandAndWaitForSuccess("lockDoor", reqObj);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fails when the hotspot is off...
|
||||
/// Note: the app uses diagnotics that also fail when the hotpot is off
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<HotspotInfo> GetHotspotInfo()
|
||||
{
|
||||
var resp = await InitiateCommandAndWait("getHotspotInfo", null);
|
||||
return resp.Body.HotspotInfo;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Send a turn-by-turn destination to the vehicle
|
||||
/// Requires both coordinates and address info
|
||||
/// Vehicle may not respond if turned off or may take a very long time to respond
|
||||
/// </summary>
|
||||
/// <param name="destination"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SendTBTRoute(TbtDestination destination)
|
||||
{
|
||||
var reqObj = new JObject()
|
||||
{
|
||||
["tbtDestination"] = new JObject(destination)
|
||||
};
|
||||
|
||||
return await InitiateCommandAndWaitForSuccess("sendTBTRoute", reqObj);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unlock the active vehicles's doors and wait for completion
|
||||
/// Privileged Command
|
||||
@@ -76,10 +110,12 @@ namespace GM.Api
|
||||
/// <returns>True or false for success</returns>
|
||||
public async Task<bool> UnlockDoor()
|
||||
{
|
||||
|
||||
var reqObj = new JObject()
|
||||
{
|
||||
["delay"] = 0
|
||||
["unlockDoorRequest"] = new JObject()
|
||||
{
|
||||
["delay"] = 0
|
||||
}
|
||||
};
|
||||
|
||||
return await InitiateCommandAndWaitForSuccess("unlockDoor", reqObj);
|
||||
@@ -113,15 +149,19 @@ namespace GM.Api
|
||||
/// <returns>True or false for success</returns>
|
||||
public async Task<bool> Alert()
|
||||
{
|
||||
|
||||
|
||||
var reqObj = new JObject()
|
||||
{
|
||||
["action"] = new JArray() { "Honk", "Flash" },
|
||||
["delay"] = 0,
|
||||
["duration"] = 1,
|
||||
["override"] = new JArray() { "DoorOpen", "IgnitionOn" }
|
||||
["alertRequest"] = new JObject()
|
||||
{
|
||||
["action"] = new JArray() { "Honk", "Flash" },
|
||||
["delay"] = 0,
|
||||
["duration"] = 1,
|
||||
["override"] = new JArray() { "DoorOpen", "IgnitionOn" }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return await InitiateCommandAndWaitForSuccess("alert", reqObj);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace GM.Api.Models
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Response boldy for commands that include a response (e.g. diagnostics, location)
|
||||
/// Response body for commands that include a response (e.g. diagnostics, location)
|
||||
/// </summary>
|
||||
[JsonProperty("body")]
|
||||
public ResponseBody Body { get; set; }
|
||||
@@ -62,4 +62,32 @@ namespace GM.Api.Models
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Response Body
|
||||
/// Note: this only contains a diagnostic response. there are likely others.
|
||||
/// </summary>
|
||||
public class ResponseBody
|
||||
{
|
||||
/// <summary>
|
||||
/// Populated for diagnostics command
|
||||
/// </summary>
|
||||
[JsonProperty("diagnosticResponse")]
|
||||
public DiagnosticResponse[] DiagnosticResponse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// populated for location command
|
||||
/// </summary>
|
||||
[JsonProperty("location")]
|
||||
public Location Location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// placeholder - not yet tested
|
||||
/// </summary>
|
||||
[JsonProperty("hotspotInfo")]
|
||||
public HotspotInfo HotspotInfo { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,16 +6,6 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace GM.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Response Body
|
||||
/// Note: this only contains a diagnostic response. there are likely others.
|
||||
/// </summary>
|
||||
public class ResponseBody
|
||||
{
|
||||
[JsonProperty("diagnosticResponse")]
|
||||
public DiagnosticResponse[] DiagnosticResponse { get; set; }
|
||||
}
|
||||
|
||||
public class DiagnosticResponse
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
|
||||
13
GM.Api/Models/HotspotInfo.cs
Normal file
13
GM.Api/Models/HotspotInfo.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace GM.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Placeholder
|
||||
/// </summary>
|
||||
public class HotspotInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
16
GM.Api/Models/Location.cs
Normal file
16
GM.Api/Models/Location.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace GM.Api.Models
|
||||
{
|
||||
public class Location
|
||||
{
|
||||
[JsonProperty("lat")]
|
||||
public float? Latitude { get; set; }
|
||||
|
||||
[JsonProperty("long")]
|
||||
public float? Longitude { get; set; }
|
||||
}
|
||||
}
|
||||
68
GM.Api/Models/TbtDestination.cs
Normal file
68
GM.Api/Models/TbtDestination.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace GM.Api.Models
|
||||
{
|
||||
|
||||
public class TbtDestination
|
||||
{
|
||||
[JsonProperty("additionalDestinationInfo")]
|
||||
public AdditionalDestinationInfo AdditionalDestinationInfo { get; set; }
|
||||
|
||||
[JsonProperty("destinationLocation")]
|
||||
public Location DestinationLocation { get; set; }
|
||||
}
|
||||
|
||||
public class AdditionalDestinationInfo
|
||||
{
|
||||
[JsonProperty("destinationAddress")]
|
||||
public DestinationAddress DestinationAddress { get; set; }
|
||||
|
||||
[JsonProperty("destinationType")]
|
||||
public string DestinationType { get; set; }
|
||||
}
|
||||
|
||||
public class DestinationAddress
|
||||
{
|
||||
[JsonProperty("city")]
|
||||
public string City { get; set; }
|
||||
|
||||
[JsonProperty("country")]
|
||||
public string Country { get; set; }
|
||||
|
||||
[JsonProperty("state")]
|
||||
public string State { get; set; }
|
||||
|
||||
[JsonProperty("street")]
|
||||
public string Street { get; set; }
|
||||
|
||||
[JsonProperty("streetNo")]
|
||||
public string StreetNo { get; set; }
|
||||
|
||||
[JsonProperty("zipCode")]
|
||||
public string ZipCode { get; set; }
|
||||
}
|
||||
|
||||
public class DestinationLocation
|
||||
{
|
||||
public void SetLatitude(float value)
|
||||
{
|
||||
Latitude = value.ToString("###.#####");
|
||||
}
|
||||
|
||||
public void SetLongitude(float value)
|
||||
{
|
||||
Longitude = value.ToString("###.#####");
|
||||
}
|
||||
|
||||
[JsonProperty("lat")]
|
||||
public string Latitude { get; set; }
|
||||
|
||||
[JsonProperty("long")]
|
||||
public string Longitude { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -246,7 +246,7 @@ namespace GM.WindowsUI
|
||||
grpActions.IsEnabled = false;
|
||||
btnLogin.IsEnabled = false;
|
||||
lblStatus.Content = "Locking (Please wait)";
|
||||
var success = await _client.LockDoor(txtPin.Password);
|
||||
var success = await _client.LockDoor();
|
||||
if (success)
|
||||
{
|
||||
lblStatus.Content = "Locked Successfully";
|
||||
@@ -266,7 +266,7 @@ namespace GM.WindowsUI
|
||||
grpActions.IsEnabled = false;
|
||||
btnLogin.IsEnabled = false;
|
||||
lblStatus.Content = "Unlocking (Please wait)";
|
||||
var success = await _client.UnlockDoor(txtPin.Password);
|
||||
var success = await _client.UnlockDoor();
|
||||
if (success)
|
||||
{
|
||||
lblStatus.Content = "Unlocked Successfully";
|
||||
@@ -285,7 +285,7 @@ namespace GM.WindowsUI
|
||||
grpActions.IsEnabled = false;
|
||||
btnLogin.IsEnabled = false;
|
||||
lblStatus.Content = "Starting (Please wait)";
|
||||
var success = await _client.Start(txtPin.Password);
|
||||
var success = await _client.Start();
|
||||
if (success)
|
||||
{
|
||||
lblStatus.Content = "Started Successfully";
|
||||
@@ -304,7 +304,7 @@ namespace GM.WindowsUI
|
||||
grpActions.IsEnabled = false;
|
||||
btnLogin.IsEnabled = false;
|
||||
lblStatus.Content = "Stopping (Please wait)";
|
||||
var success = await _client.CancelStart(txtPin.Password);
|
||||
var success = await _client.CancelStart();
|
||||
if (success)
|
||||
{
|
||||
lblStatus.Content = "Stopped Successfully";
|
||||
@@ -323,7 +323,7 @@ namespace GM.WindowsUI
|
||||
grpActions.IsEnabled = false;
|
||||
btnLogin.IsEnabled = false;
|
||||
lblStatus.Content = "Alarming (Please wait)";
|
||||
var success = await _client.Alert(txtPin.Password);
|
||||
var success = await _client.Alert();
|
||||
if (success)
|
||||
{
|
||||
lblStatus.Content = "Alarmed Successfully";
|
||||
@@ -342,7 +342,7 @@ namespace GM.WindowsUI
|
||||
grpActions.IsEnabled = false;
|
||||
btnLogin.IsEnabled = false;
|
||||
lblStatus.Content = "Stopping Alarm (Please wait)";
|
||||
var success = await _client.CancelAlert(txtPin.Password);
|
||||
var success = await _client.CancelAlert();
|
||||
if (success)
|
||||
{
|
||||
lblStatus.Content = "Alarmed Stopped Successfully";
|
||||
|
||||
Reference in New Issue
Block a user