Skip to content

Commit

Permalink
Add erase-guest-data command
Browse files Browse the repository at this point in the history
Erases user's data from the user interface. Requires the vehicle to be
parked and in Guest Mode.
  • Loading branch information
Seth Terashima committed Jul 29, 2024
1 parent 05bc5dd commit f543a7d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/tesla-control/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
}
2 changes: 2 additions & 0 deletions pkg/proxy/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
11 changes: 11 additions & 0 deletions pkg/vehicle/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
},
})
}

0 comments on commit f543a7d

Please sign in to comment.