Adding cmake option ENABLE_UP_BUTTON to enable/disable user presence confirmation via button. Enabled by default.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2022-09-23 09:21:32 +02:00
parent cbfe66e89b
commit e94f6843e5
2 changed files with 13 additions and 0 deletions

View File

@@ -263,21 +263,25 @@ void init_fido(bool core1) {
bool wait_button_pressed() {
uint32_t val = EV_PRESS_BUTTON;
#if defined(ENABLE_UP_BUTTON) && ENABLE_UP_BUTTON==1
queue_try_add(&card_to_usb_q, &val);
do {
queue_remove_blocking(&usb_to_card_q, &val);
} while (val != EV_BUTTON_PRESSED && val != EV_BUTTON_TIMEOUT);
#endif
return (val == EV_BUTTON_TIMEOUT);
}
uint32_t user_present_time_limit = 0;
bool check_user_presence() {
#if defined(ENABLE_UP_BUTTON) && ENABLE_UP_BUTTON==1
if (user_present_time_limit == 0 || user_present_time_limit+TRANSPORT_TIME_LIMIT < board_millis()) {
if (wait_button_pressed() == true) //timeout
return false;
user_present_time_limit = board_millis();
}
#endif
return true;
}