Skip to content

Commit

Permalink
lib_standard_app/io.c: Send RAPDU immediately and use IO_CONTINUE_RX …
Browse files Browse the repository at this point in the history
…flag
  • Loading branch information
Xavier Chapron committed Feb 7, 2024
1 parent aaded6e commit e255f0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makefile.standard_app
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ ifneq ($(DISABLE_STANDARD_APP_FILES), 1)
SDK_SOURCE_PATH += lib_standard_app
endif

ifneq ($(DISABLE_STANDARD_APP_SYNC_RAPDU), 1)
ifneq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += STANDARD_APP_SYNC_RAPDU
endif
endif

#####################################################################
# NBGL #
#####################################################################
Expand Down
10 changes: 9 additions & 1 deletion lib_standard_app/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ WEAK int io_recv_command()

switch (G_io_state) {
case READY:
ret = io_exchange(CHANNEL_APDU | IO_CONTINUE_RX, G_output_len);
G_io_state = RECEIVED;
ret = io_exchange(CHANNEL_APDU, G_output_len);
break;
case RECEIVED:
G_io_state = WAITING;
Expand Down Expand Up @@ -198,9 +198,17 @@ WEAK int io_send_response_buffers(const buffer_t *rdatalist, size_t count, uint1
ret = -1;
break;
case RECEIVED:
#ifdef STANDARD_APP_SYNC_RAPDU
// Send synchronously the APDU response.
// This is needed to send the response before displaying synchronous
// status message on the screen.
// This is not always done to spare the RAM (stack) on LNS.
__attribute__((fallthrough));
#else
G_io_state = READY;
ret = 0;
break;
#endif
case WAITING:
ret = io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, G_output_len);
G_output_len = 0;
Expand Down

0 comments on commit e255f0f

Please sign in to comment.