From cc43ad2b4192f833bce1bd41d4646d5c0da80e68 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Thu, 7 Jan 2021 09:17:18 -0500 Subject: [PATCH] vial: allow resuming an interrupted unlock sequence --- quantum/via.c | 11 ++++++++--- quantum/vial.c | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/quantum/via.c b/quantum/via.c index 9772ea2b5e..20f33e889e 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -220,9 +220,14 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { uint8_t *command_data = &(data[1]); #ifdef VIAL_ENABLE - /* When unlock is in progress, only command we react to is unlock_poll */ - if (vial_unlock_in_progress && (data[0] != id_vial_prefix || data[1] != vial_unlock_poll)) - goto skip; + /* When unlock is in progress, we can only react to a subset of commands */ + if (vial_unlock_in_progress) { + if (data[0] != id_vial_prefix) + goto skip; + uint8_t cmd = data[1]; + if (cmd != vial_get_keyboard_id && cmd != vial_get_size && cmd != vial_get_def && cmd != vial_get_unlock_status && cmd != vial_unlock_start && cmd != vial_unlock_poll) + goto skip; + } #endif switch (*command_id) { diff --git a/quantum/vial.c b/quantum/vial.c index 8499e0a150..3261b0f4ff 100644 --- a/quantum/vial.c +++ b/quantum/vial.c @@ -105,7 +105,8 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) { memset(msg, 0xFF, length); /* First byte of message contains the status: whether board is unlocked */ msg[0] = vial_unlocked; - msg[1] = 0; + /* Second byte is whether unlock is in progress */ + msg[1] = vial_unlock_in_progress; #ifndef VIAL_INSECURE /* Rest of the message are keys in the matrix that should be held to unlock the board */ for (size_t i = 0; i < VIAL_UNLOCK_NUM_KEYS; ++i) {