Skip to content

Commit

Permalink
BLE location support
Browse files Browse the repository at this point in the history
Add support for fetching vehicle location over BLE. This requires
vehicle firmware 2024.44+.

Clients wishing to fetch location information over the Internet should
use Tesla Fleet Telemetry
(https://github.com/teslamotors/fleet-telemetry).
  • Loading branch information
Seth Terashima authored and sethterashima committed Dec 17, 2024
1 parent 7457011 commit 8e16f0d
Show file tree
Hide file tree
Showing 11 changed files with 4,333 additions and 3,368 deletions.
1 change: 1 addition & 0 deletions cmd/tesla-control/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var categoriesByName = map[string]vehicle.StateCategory{
"charge": vehicle.StateCategoryCharge,
"climate": vehicle.StateCategoryClimate,
"drive": vehicle.StateCategoryDrive,
"location": vehicle.StateCategoryLocation,
"closures": vehicle.StateCategoryClosures,
"charge-schedule": vehicle.StateCategoryChargeSchedule,
"precondition-schedule": vehicle.StateCategoryPreconditioningSchedule,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/teslamotors/vehicle-command

go 1.23.0
go 1.23

require (
github.com/99designs/keyring v1.2.2
Expand Down
3 changes: 2 additions & 1 deletion pkg/protocol/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ type RoutableMessageError struct {
}

func (v *RoutableMessageError) MayHaveSucceeded() bool {
return v.Code == universal.MessageFault_E_MESSAGEFAULT_ERROR_NONE
return v.Code == universal.MessageFault_E_MESSAGEFAULT_ERROR_NONE ||
v.Code == universal.MessageFault_E_MESSAGEFAULT_ERROR_RESPONSE_MTU_EXCEEDED
}

// retriableErrors can sometimes be remedied if the client retries the command,
Expand Down
10 changes: 10 additions & 0 deletions pkg/protocol/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func TestRetriableError(t *testing.T) {
shouldRetry = false
case universal.MessageFault_E_MESSAGEFAULT_ERROR_COMMAND_REQUIRES_ACCOUNT_CREDENTIALS:
shouldRetry = false
case universal.MessageFault_E_MESSAGEFAULT_ERROR_REQUEST_MTU_EXCEEDED:
shouldRetry = false
case universal.MessageFault_E_MESSAGEFAULT_ERROR_RESPONSE_MTU_EXCEEDED:
shouldRetry = false
case universal.MessageFault_E_MESSAGEFAULT_ERROR_REPEATED_COUNTER:
shouldRetry = false
case universal.MessageFault_E_MESSAGEFAULT_ERROR_INVALID_KEY_HANDLE:
shouldRetry = false
case universal.MessageFault_E_MESSAGEFAULT_ERROR_REQUIRES_RESPONSE_ENCRYPTION:
shouldRetry = false
default:
t.Fatalf("No expected retry behavior specified for %s", message)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/protocol/protobuf/car_server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ message GetVehicleData {
GetChargeState getChargeState = 2;
GetClimateState getClimateState = 3;
GetDriveState getDriveState = 4;
reserved 5, 6, 7;
reserved 5, 6;
GetLocationState getLocationState = 7;
GetClosuresState getClosuresState = 8;
GetChargeScheduleState getChargeScheduleState = 10;
GetPreconditioningScheduleState getPreconditioningScheduleState = 11;
Expand Down Expand Up @@ -113,6 +114,9 @@ message GetClimateState {
message GetDriveState {
}

message GetLocationState {
}

message GetClosuresState {
}

Expand Down
Loading

0 comments on commit 8e16f0d

Please sign in to comment.