Skip to content

Commit

Permalink
Add setter functions in ux_sync lib for synchronous call return code …
Browse files Browse the repository at this point in the history
…and "end of flow" variables.
  • Loading branch information
agrojean-ledger committed Jun 24, 2024
1 parent 434dc29 commit 6bb92cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
4 changes: 3 additions & 1 deletion lib_ux_sync/include/ux_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ typedef enum {
UX_SYNC_RET_ERROR
} ux_sync_ret_t;

void ux_sync_genericContentActionCallback(int token, uint8_t index, int page);
void ux_sync_setReturnCode(ux_sync_ret_t ret);

void ux_sync_setEnded(bool ended);

ux_sync_ret_t ux_sync_homeAndSettings(const char *appName,
const nbgl_icon_details_t *appIcon,
Expand Down
37 changes: 15 additions & 22 deletions lib_ux_sync/src/ux_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,25 @@ static ux_sync_ret_t ux_sync_wait(bool exitOnApdu)
}

/**
* @brief Callback to be used when filling the nbgl_contentActionCallback_t of nbgl_content_t
* structures used with the ux_sync_genericReview function. It will be called to confirm or reject a
* flow when the user touches a button (e.g. with nbgl_contentInfoButton_t) or long press button
* (e.g. with nbgl_contentInfoLongPress_t). The callback is triggered and is passed
* the token of the button that was touched. The button used to confirm the flow should
* have the token FIRST_USER_TOKEN. Other tokens will be considered as rejection of the flow.
* @brief Sets the return code of synchronous UX calls. Can be used by content action callbacks
* defined by application code.
*
* @note This callback does not enable usage of more advanced generic content flows
* for instance when using nbgl_contentSwitchesList_t or nbgl_contentBarsList_t.
* @param ret return code to set.
*/
void ux_sync_setReturnCode(ux_sync_ret_t ret)
{
g_ret = ret;
}

/**
* @brief Sets the ended flag of synchronous UX calls. Can be used by content action callbacks
* defined by application code to end the UX flow.
*
* @param token integer passed at content object initialization
* @param index when the object touched is a list of radio buttons, gives the index of the activated
* @param page index of the current page, can be used to restart the use_case directly at the right
* page button
* @param ended flag to set.
*/
void ux_sync_genericContentActionCallback(int token, uint8_t index, int page)
void ux_sync_setEnded(bool ended)
{
UNUSED(index);
UNUSED(page);
if (token == FIRST_USER_TOKEN) {
g_ret = UX_SYNC_RET_APPROVED;
}
else {
g_ret = UX_SYNC_RET_REJECTED;
}
g_ended = true;
g_ended = ended;
}

/**
Expand Down

0 comments on commit 6bb92cd

Please sign in to comment.