mirror of
https://github.com/polhenarejos/pico-fido.git
synced 2025-12-18 09:30:04 +08:00
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:
@@ -28,6 +28,15 @@ pico_sdk_init()
|
|||||||
|
|
||||||
add_executable(pico_fido)
|
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
|
target_sources(pico_fido PUBLIC
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/fido.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/fido.c
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/files.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/files.c
|
||||||
|
|||||||
@@ -263,21 +263,25 @@ void init_fido(bool core1) {
|
|||||||
|
|
||||||
bool wait_button_pressed() {
|
bool wait_button_pressed() {
|
||||||
uint32_t val = EV_PRESS_BUTTON;
|
uint32_t val = EV_PRESS_BUTTON;
|
||||||
|
#if defined(ENABLE_UP_BUTTON) && ENABLE_UP_BUTTON==1
|
||||||
queue_try_add(&card_to_usb_q, &val);
|
queue_try_add(&card_to_usb_q, &val);
|
||||||
do {
|
do {
|
||||||
queue_remove_blocking(&usb_to_card_q, &val);
|
queue_remove_blocking(&usb_to_card_q, &val);
|
||||||
} while (val != EV_BUTTON_PRESSED && val != EV_BUTTON_TIMEOUT);
|
} while (val != EV_BUTTON_PRESSED && val != EV_BUTTON_TIMEOUT);
|
||||||
|
#endif
|
||||||
return (val == EV_BUTTON_TIMEOUT);
|
return (val == EV_BUTTON_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t user_present_time_limit = 0;
|
uint32_t user_present_time_limit = 0;
|
||||||
|
|
||||||
bool check_user_presence() {
|
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 (user_present_time_limit == 0 || user_present_time_limit+TRANSPORT_TIME_LIMIT < board_millis()) {
|
||||||
if (wait_button_pressed() == true) //timeout
|
if (wait_button_pressed() == true) //timeout
|
||||||
return false;
|
return false;
|
||||||
user_present_time_limit = board_millis();
|
user_present_time_limit = board_millis();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user