From f543a7dd6dd00c69676085c29f0ddc4c108bc043 Mon Sep 17 00:00:00 2001 From: Seth Terashima Date: Mon, 1 Jul 2024 13:35:06 -0700 Subject: [PATCH] Add erase-guest-data command Erases user's data from the user interface. Requires the vehicle to be parked and in Guest Mode. --- cmd/tesla-control/commands.go | 8 ++++++++ pkg/proxy/command.go | 2 ++ pkg/vehicle/security.go | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/cmd/tesla-control/commands.go b/cmd/tesla-control/commands.go index 026406f..9d2e067 100644 --- a/cmd/tesla-control/commands.go +++ b/cmd/tesla-control/commands.go @@ -819,4 +819,12 @@ var commands = map[string]*Command{ return nil }, }, + "erase-guest-data": &Command{ + help: "Erase Guest Mode user data", + requiresAuth: true, + requiresFleetAPI: false, + handler: func(ctx context.Context, acct *account.Account, car *vehicle.Vehicle, args map[string]string) error { + return car.EraseGuestData(ctx) + }, + }, } diff --git a/pkg/proxy/command.go b/pkg/proxy/command.go index 84574cf..f250a6b 100644 --- a/pkg/proxy/command.go +++ b/pkg/proxy/command.go @@ -261,6 +261,8 @@ func ExtractCommandAction(ctx context.Context, command string, params RequestPar return func(v *vehicle.Vehicle) error { return v.Lock(ctx) }, nil case "door_unlock": return func(v *vehicle.Vehicle) error { return v.Unlock(ctx) }, nil + case "erase_user_data": + return func(v *vehicle.Vehicle) error { return v.EraseGuestData(ctx) }, nil case "reset_pin_to_drive_pin": return func(v *vehicle.Vehicle) error { return v.ResetPIN(ctx) }, nil case "reset_valet_pin": diff --git a/pkg/vehicle/security.go b/pkg/vehicle/security.go index d7a0342..27cbae1 100644 --- a/pkg/vehicle/security.go +++ b/pkg/vehicle/security.go @@ -294,3 +294,14 @@ func (v *Vehicle) SendAddKeyRequestWithRole(ctx context.Context, publicKey *ecdh } return v.conn.Send(ctx, encodedEnvelope) } + +// EraseGuestData erases user data created while in Guest Mode. This command has no effect unless +// the vehicle is currently in Guest Mode. +func (v *Vehicle) EraseGuestData(ctx context.Context) error { + return v.executeCarServerAction(ctx, + &carserver.Action_VehicleAction{ + VehicleAction: &carserver.VehicleAction{ + VehicleActionMsg: &carserver.VehicleAction_EraseUserDataAction{}, + }, + }) +}