From ec962ae1e761ccc952bf9d3bfa6a2ee08153c002 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Wed, 27 Oct 2021 09:17:12 +0300 Subject: [PATCH] add factory reset --- flow_commands.go | 14 ++++++++------ keycard_context.go | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/flow_commands.go b/flow_commands.go index 6af7afb..e42d8a5 100644 --- a/flow_commands.go +++ b/flow_commands.go @@ -1,12 +1,14 @@ package statuskeycardgo -import "errors" - func (f *KeycardFlow) factoryReset(kc *keycardContext) error { - // on success, remove the FactoryReset switch to avoid re-triggering it - // if card is disconnected/reconnected - delete(f.params, FactoryReset) - return errors.New("not implemented") + err := kc.factoryReset() + + if err == nil { + delete(f.params, FactoryReset) + return restartErr() + } else { + return err + } } func (f *KeycardFlow) selectKeycard(kc *keycardContext) error { diff --git a/keycard_context.go b/keycard_context.go index 89156aa..9ac687f 100644 --- a/keycard_context.go +++ b/keycard_context.go @@ -463,7 +463,7 @@ func (kc *keycardContext) changePairingPassword(pairingPassword string) error { return nil } -func (kc *keycardContext) factoryReset(pairingPassword string) error { +func (kc *keycardContext) factoryReset() error { <-kc.connected if kc.runErr != nil { return kc.runErr