diff --git a/src/main.rs b/src/main.rs index 8b59bf5..446a3a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,6 @@ fn main() -> ! { let cmd = block!(serial.read()).unwrap_or(u8::MAX); match cmd { - EXIT => {} HANDSHAKE => serial.write(OK).unwrap(), SET_TIMESTAMP => { serial.write(OK).unwrap(); diff --git a/tools/menu.py b/tools/menu.py index 0cea0fb..bcddd21 100644 --- a/tools/menu.py +++ b/tools/menu.py @@ -13,8 +13,9 @@ SET_TIMESTAMP = bytes([10]) ADD_TOKEN = bytes([20]) DELETE_TOKEN = bytes([30]) GET_TOKENS = bytes([40]) -WIPE_TOKENS = bytes([50]) -EXIT = bytes([254]) +SOFT_WIPE_TOKENS = bytes([50]) +HARD_WIPE_TOKENS = bytes([60]) +EXIT = bytes([255]) def loop_input(msg: str, valid_values: Any) -> str: valid_values = list(map(str, valid_values)) @@ -71,10 +72,11 @@ def main(argv: list[str]): print("1) Update timestamp") print("2) Add a new token") print("3) Remove a token") - print("4) WIPE ALL THE TOKENS") - print("5) EXIT") + print("4) SOFT wipe all tokens") + print("5) HARD WIPE ALL THE TOKENS") + print("6) EXIT") - opt = loop_input(">>> ", range(1, 6)) + opt = loop_input(">>> ", range(1, 7)) # Update Timestamp if opt == "1": @@ -125,13 +127,26 @@ def main(argv: list[str]): print("Token added successfully!") # Wipe tokens elif opt == "4": - conn.write(WIPE_TOKENS) + conn.write(SOFT_WIPE_TOKENS) sleep(0.1) _ = conn.read() resp = conn.read() if resp == OK: print("All the tokens wipped successfully!") + else: + print("Error!!") elif opt == "5": + resp = loop_input("This will erase all the EEPROM, do you want to continue? [Y/N]", ["y", "Y", "n", "N"]).upper() + if resp == "Y": + conn.write(HARD_WIPE_TOKENS) + sleep(0.1) + resp = conn.read() + if resp == OK: + print("All the Eeprom erased successfully!") + else: + print("Error!!") + elif opt == "6": + conn.write(EXIT) return 0 if __name__ == "__main__":