From 2aff75a3ecba884bfc4d701b68b767a33b6555d0 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Tue, 27 Sep 2022 22:09:16 +0200 Subject: [PATCH] Fix keepalive msg. Only sent when CBOR is initiatied. Signed-off-by: Pol Henarejos --- src/usb/hid/hid.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/usb/hid/hid.c b/src/usb/hid/hid.c index 192d50d..2cafd46 100644 --- a/src/usb/hid/hid.c +++ b/src/usb/hid/hid.c @@ -326,7 +326,8 @@ void send_keepalive() { } void driver_exec_timeout() { - send_keepalive(); + if (thread_type == 2) + send_keepalive(); } uint8_t *driver_prepare_response() { @@ -338,10 +339,12 @@ uint8_t *driver_prepare_response() { } void driver_exec_finished(size_t size_next) { - if (thread_type == 2 && apdu.sw != 0) - ctap_error(apdu.sw & 0xff); - else - driver_exec_finished_cont(size_next, 7); + if (size_next > 0) { + if (thread_type == 2 && apdu.sw != 0) + ctap_error(apdu.sw & 0xff); + else + driver_exec_finished_cont(size_next, 7); + } apdu.sw = 0; }