Blink LED rapidly when asking ACK from user.
This commit is contained in:
@@ -445,6 +445,7 @@ extern const uint8_t gnuk_string_serial[];
|
||||
#define LED_GNUK_EXEC 32
|
||||
#define LED_START_COMMAND 64
|
||||
#define LED_FINISH_COMMAND 128
|
||||
#define LED_WAIT_FOR_BUTTON 256
|
||||
#define LED_OFF LED_FINISH_COMMAND
|
||||
void led_blink (int spec);
|
||||
|
||||
|
||||
13
src/main.c
13
src/main.c
@@ -238,6 +238,7 @@ main (int argc, const char *argv[])
|
||||
uintptr_t entry;
|
||||
#endif
|
||||
chopstx_t ccid_thd;
|
||||
int wait_for_ack = 0;
|
||||
|
||||
chopstx_conf_idle (1);
|
||||
|
||||
@@ -354,7 +355,11 @@ main (int argc, const char *argv[])
|
||||
{
|
||||
eventmask_t m;
|
||||
|
||||
m = eventflag_wait (&led_event);
|
||||
if (wait_for_ack)
|
||||
m = eventflag_wait_timeout (&led_event, LED_TIMEOUT_INTERVAL);
|
||||
else
|
||||
m = eventflag_wait (&led_event);
|
||||
|
||||
switch (m)
|
||||
{
|
||||
case LED_ONESHOT:
|
||||
@@ -371,12 +376,16 @@ main (int argc, const char *argv[])
|
||||
display_fatal_code ();
|
||||
break;
|
||||
case LED_SYNC:
|
||||
wait_for_ack = 0;
|
||||
set_led (led_inverted);
|
||||
break;
|
||||
case LED_GNUK_EXEC:
|
||||
goto exec;
|
||||
case LED_WAIT_FOR_BUTTON:
|
||||
wait_for_ack = 1;
|
||||
/* fall through */
|
||||
default:
|
||||
emit_led (LED_TIMEOUT_ZERO, LED_TIMEOUT_STOP);
|
||||
emit_led (LED_TIMEOUT_ONE, LED_TIMEOUT_ZERO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1644,8 +1644,7 @@ openpgp_card_thread (void *arg)
|
||||
|
||||
led_blink (LED_START_COMMAND);
|
||||
r = process_command_apdu ();
|
||||
if (!r)
|
||||
led_blink (LED_FINISH_COMMAND);
|
||||
led_blink (LED_FINISH_COMMAND);
|
||||
done:
|
||||
eventflag_signal (ccid_comm, r? EV_EXEC_FINISHED_ACK : EV_EXEC_FINISHED);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef ACKBTN_SUPPORT
|
||||
#include <contrib/ackbtn.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "usb-cdc.h"
|
||||
#include "debug.h"
|
||||
@@ -1844,6 +1848,7 @@ ccid_thread (void *arg)
|
||||
if (c->ccid_state == CCID_STATE_EXECUTE)
|
||||
{
|
||||
ackbtn_enable ();
|
||||
led_blink (LED_WAIT_FOR_BUTTON);
|
||||
c->ccid_state = CCID_STATE_CONFIRM_ACK;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user