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
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
2 changed files with 13 additions and 0 deletions

View File

@ -28,6 +28,15 @@ pico_sdk_init()
add_executable(pico_fido)
option(ENABLE_UP_BUTTON "Enable/disable user presence button" ON)
if(ENABLE_UP_BUTTON)
add_definitions(-DENABLE_UP_BUTTON=1)
message("Enabling user presence with button")
else()
add_definitions(-DENABLE_UP_BUTTON=0)
message("Disabling user presence with button")
endif(ENABLE_UP_BUTTON)
target_sources(pico_fido PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/fido/fido.c
${CMAKE_CURRENT_LIST_DIR}/src/fido/files.c

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;
}