Embedded SDK
Embedded SDK
nbgl_use_case.h
Go to the documentation of this file.
1 
7 #ifndef NBGL_USE_CASE_H
8 #define NBGL_USE_CASE_H
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 /*********************
15  * INCLUDES
16  *********************/
17 
18 #include "nbgl_content.h"
19 #ifdef NBGL_PAGE
20 #include "nbgl_page.h"
21 #else // NBGL_PAGE
22 #include "nbgl_flow.h"
23 #endif // NBGL_PAGE
24 
25 /*********************
26  * DEFINES
27  *********************/
32 #define FIRST_USER_TOKEN 20
33 
38 #define LAST_PAGE_FOR_REVIEW 0xFF
39 
43 #ifdef TARGET_STAX
44 #define NB_MAX_LINES_IN_DETAILS 12
45 #else // TARGET_STAX
46 #define NB_MAX_LINES_IN_DETAILS 11
47 #endif // TARGET_STAX
48 
52 #ifdef TARGET_STAX
53 #define NB_MAX_LINES_IN_REVIEW 10
54 #else // TARGET_STAX
55 #define NB_MAX_LINES_IN_REVIEW 9
56 #endif // TARGET_STAX
57 
63 #define NB_MAX_DISPLAYED_PAIRS_IN_REVIEW 4
64 
68 #define TAG_VALUE_AREA_HEIGHT (SCREEN_HEIGHT - SMALL_CENTERING_HEADER - SIMPLE_FOOTER_HEIGHT)
69 
73 #define INFOS_AREA_HEIGHT (SCREEN_HEIGHT - TOUCHABLE_HEADER_BAR_HEIGHT)
74 
78 #define TAGLINE_PART1 "This app enables signing\ntransactions on the"
79 #define TAGLINE_PART2 "network."
80 
84 #define APP_DESCRIPTION_MAX_LEN 74
85 
89 #define MAX_APP_NAME_FOR_SDK_TAGLINE \
90  (APP_DESCRIPTION_MAX_LEN - 1 - (sizeof(TAGLINE_PART1) + sizeof(TAGLINE_PART2)))
91 
97 #define INIT_HOME_PAGE 0xff
98 
99 /**********************
100  * MACROS
101  **********************/
102 
103 /**********************
104  * TYPEDEFS
105  **********************/
109 typedef void (*nbgl_callback_t)(void);
110 
117 typedef bool (*nbgl_navCallback_t)(uint8_t page, nbgl_pageContent_t *content);
118 
123 typedef void (*nbgl_choiceCallback_t)(bool confirm);
124 
129 typedef void (*nbgl_actionCallback_t)(uint8_t page);
130 
136 typedef void (*nbgl_pinValidCallback_t)(const uint8_t *content, uint8_t page);
137 
143 typedef void (*nbgl_contentCallback_t)(uint8_t contentIndex, nbgl_content_t *content);
144 
145 typedef struct {
148  union {
152  };
155 
160 typedef enum {
164 
169 typedef struct {
170  const char *text;
175 
181 typedef struct {
182  const char *text;
184  const char *modalTitle;
186  union {
188  };
189 } nbgl_tipBox_t;
190 
195 typedef enum {
197  = 0,
198  TYPE_MESSAGE,
202 
208 #define SKIPPABLE_OPERATION (1 << 4)
209 
215 #define BLIND_OPERATION (1 << 5)
216 
222 typedef uint32_t nbgl_operationType_t;
223 
228 typedef enum {
238 
239 /**********************
240  * GLOBAL PROTOTYPES
241  **********************/
242 
243 void nbgl_useCaseHomeAndSettings(const char *appName,
244  const nbgl_icon_details_t *appIcon,
245  const char *tagline,
246  const uint8_t initSettingPage,
247  const nbgl_genericContents_t *settingContents,
248  const nbgl_contentInfoList_t *infosList,
249  const nbgl_homeAction_t *action,
250  nbgl_callback_t quitCallback);
251 
253  const nbgl_contentTagValueList_t *tagValueList,
254  const nbgl_icon_details_t *icon,
255  const char *reviewTitle,
256  const char *reviewSubTitle,
257  const char *finishTitle,
258  nbgl_choiceCallback_t choiceCallback);
259 
261  const nbgl_contentTagValueList_t *tagValueList,
262  const nbgl_icon_details_t *icon,
263  const char *reviewTitle,
264  const char *reviewSubTitle,
265  const char *finishTitle,
266  const nbgl_tipBox_t *tipBox,
267  nbgl_choiceCallback_t choiceCallback);
268 
270  const nbgl_contentTagValueList_t *tagValueList,
271  const nbgl_icon_details_t *icon,
272  const char *reviewTitle,
273  const char *reviewSubTitle,
274  const char *finishTitle,
275  const nbgl_tipBox_t *tipBox,
276  nbgl_choiceCallback_t choiceCallback);
277 
279  const nbgl_contentTagValueList_t *tagValueList,
280  const nbgl_icon_details_t *icon,
281  const char *reviewTitle,
282  const char *reviewSubTitle,
283  const char *finishTitle,
284  nbgl_choiceCallback_t choiceCallback);
285 
286 void nbgl_useCaseAddressReview(const char *address,
287  const nbgl_contentTagValueList_t *additionalTagValueList,
288  const nbgl_icon_details_t *icon,
289  const char *reviewTitle,
290  const char *reviewSubTitle,
291  nbgl_choiceCallback_t choiceCallback);
292 
294  nbgl_callback_t quitCallback);
295 
297  const nbgl_icon_details_t *icon,
298  const char *reviewTitle,
299  const char *reviewSubTitle,
300  nbgl_choiceCallback_t choiceCallback);
301 
303  const nbgl_icon_details_t *icon,
304  const char *reviewTitle,
305  const char *reviewSubTitle,
306  nbgl_choiceCallback_t choiceCallback);
307 
309  nbgl_choiceCallback_t choiceCallback,
310  nbgl_callback_t skipCallback);
311 
313  nbgl_choiceCallback_t choiceCallback);
314 
315 void nbgl_useCaseReviewStreamingFinish(const char *finishTitle,
316  nbgl_choiceCallback_t choiceCallback);
317 
319  const char *rejectText,
320  nbgl_callback_t rejectCallback);
321 
322 void nbgl_useCaseGenericConfiguration(const char *title,
323  uint8_t initPage,
324  const nbgl_genericContents_t *contents,
325  nbgl_callback_t quitCallback);
326 
328  const char *message,
329  const char *subMessage,
330  const char *confirmText,
331  const char *rejectString,
332  nbgl_choiceCallback_t callback);
333 
334 void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t quitCallback);
335 
336 void nbgl_useCaseSpinner(const char *text);
337 
338 #ifdef HAVE_SE_TOUCH
339 // utils
341  const nbgl_contentTagValueList_t *tagValueList,
342  uint8_t startIndex,
343  bool *requireSpecificDisplay);
345  const nbgl_contentTagValueList_t *tagValueList,
346  uint8_t startIndex,
347  bool isSkippable,
348  bool *requireSpecificDisplay);
350  const nbgl_contentInfoList_t *infosList,
351  uint8_t startIndex,
352  bool withNav);
354  const nbgl_contentSwitchesList_t *switchesList,
355  uint8_t startIndex,
356  bool withNav);
358  const nbgl_contentBarsList_t *barsList,
359  uint8_t startIndex,
360  bool withNav);
362  const nbgl_contentRadioChoice_t *choicesList,
363  uint8_t startIndex,
364  bool withNav);
366 
367 // use case drawing
368 DEPRECATED void nbgl_useCaseHome(const char *appName,
369  const nbgl_icon_details_t *appIcon,
370  const char *tagline,
371  bool withSettings,
372  nbgl_callback_t topRightCallback,
373  nbgl_callback_t quitCallback);
374 DEPRECATED void nbgl_useCaseHomeExt(const char *appName,
375  const nbgl_icon_details_t *appIcon,
376  const char *tagline,
377  bool withSettings,
378  const char *actionButtonText,
379  nbgl_callback_t actionCallback,
380  nbgl_callback_t topRightCallback,
381  nbgl_callback_t quitCallback);
382 void nbgl_useCaseNavigableContent(const char *title,
383  uint8_t initPage,
384  uint8_t nbPages,
385  nbgl_callback_t quitCallback,
386  nbgl_navCallback_t navCallback,
387  nbgl_layoutTouchCallback_t controlsCallback);
388 DEPRECATED void nbgl_useCaseSettings(const char *settingsTitle,
389  uint8_t initPage,
390  uint8_t nbPages,
391  bool touchableTitle,
392  nbgl_callback_t quitCallback,
393  nbgl_navCallback_t navCallback,
394  nbgl_layoutTouchCallback_t controlsCallback);
395 void nbgl_useCaseGenericSettings(const char *appName,
396  uint8_t initPage,
397  const nbgl_genericContents_t *settingContents,
398  const nbgl_contentInfoList_t *infosList,
399  nbgl_callback_t quitCallback);
400 void nbgl_useCaseConfirm(const char *message,
401  const char *subMessage,
402  const char *confirmText,
403  const char *rejectText,
404  nbgl_callback_t callback);
406  const char *reviewTitle,
407  const char *reviewSubTitle,
408  const char *rejectText,
409  nbgl_callback_t continueCallback,
410  nbgl_callback_t rejectCallback);
412  uint8_t nbPages,
413  const char *rejectText,
414  nbgl_layoutTouchCallback_t buttonCallback,
415  nbgl_navCallback_t navCallback,
416  nbgl_choiceCallback_t choiceCallback);
418  const nbgl_pageInfoLongPress_t *infoLongPress,
419  const char *rejectText,
420  nbgl_choiceCallback_t callback);
422  const nbgl_pageInfoLongPress_t *infoLongPress,
423  const char *rejectText,
424  nbgl_choiceCallback_t callback);
425 
426 DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address,
427  nbgl_choiceCallback_t callback,
428  const nbgl_contentTagValueList_t *tagValueList);
429 #define nbgl_useCaseAddressConfirmation(__address, __callback) \
430  nbgl_useCaseAddressConfirmationExt(__address, __callback, NULL)
431 
432 #ifdef NBGL_KEYPAD
433 void nbgl_useCaseKeypadDigits(const char *title,
434  uint8_t minDigits,
435  uint8_t maxDigits,
436  uint8_t backToken,
437  bool shuffled,
438  tune_index_e tuneId,
439  nbgl_pinValidCallback_t validatePinCallback,
440  nbgl_layoutTouchCallback_t actionCallback);
441 void nbgl_useCaseKeypadPIN(const char *title,
442  uint8_t minDigits,
443  uint8_t maxDigits,
444  uint8_t backToken,
445  bool shuffled,
446  tune_index_e tuneId,
447  nbgl_pinValidCallback_t validatePinCallback,
448  nbgl_layoutTouchCallback_t actionCallback);
449 #endif // NBGL_KEYPAD
450 #endif // HAVE_SE_TOUCH
451 
452 #ifdef __cplusplus
453 } /* extern "C" */
454 #endif
455 
456 #endif /* NBGL_USE_CASE_H */
common content for Graphical Library
nbgl_contentType_t
The different types of predefined contents.
Definition: nbgl_content.h:340
Flow construction API of NBGL.
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
Definition: nbgl_layout.h:104
API of the Advanced BOLOS Graphical Library, for predefined pages.
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
DEPRECATED void nbgl_useCaseHome(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, bool withSettings, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback)
DEPRECATED void nbgl_useCaseSettings(const char *settingsTitle, uint8_t initPage, uint8_t nbPages, bool touchableTitle, nbgl_callback_t quitCallback, nbgl_navCallback_t navCallback, nbgl_layoutTouchCallback_t controlsCallback)
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool isSkippable, bool *requireSpecificDisplay)
void(* nbgl_callback_t)(void)
prototype of generic callback function
void nbgl_useCaseGenericSettings(const char *appName, uint8_t initPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, nbgl_callback_t quitCallback)
void nbgl_useCaseKeypadPIN(const char *title, uint8_t minDigits, uint8_t maxDigits, uint8_t backToken, bool shuffled, tune_index_e tuneId, nbgl_pinValidCallback_t validatePinCallback, nbgl_layoutTouchCallback_t actionCallback)
uint32_t nbgl_operationType_t
This mask is used to describe the type of operation to review with additional options It is a mask of...
void nbgl_useCaseReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool *requireSpecificDisplay)
uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList)
void nbgl_useCaseReviewStreamingStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseHomeAndSettings(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, const uint8_t initSettingPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, const nbgl_homeAction_t *action, nbgl_callback_t quitCallback)
void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback)
uint8_t nbgl_useCaseGetNbInfosInPage(uint8_t nbInfos, const nbgl_contentInfoList_t *infosList, uint8_t startIndex, bool withNav)
void(* nbgl_choiceCallback_t)(bool confirm)
prototype of choice callback function
uint8_t nbgl_useCaseGetNbBarsInPage(uint8_t nbBars, const nbgl_contentBarsList_t *barsList, uint8_t startIndex, bool withNav)
void nbgl_useCaseNavigableContent(const char *title, uint8_t initPage, uint8_t nbPages, nbgl_callback_t quitCallback, nbgl_navCallback_t navCallback, nbgl_layoutTouchCallback_t controlsCallback)
nbgl_homeActionStyle_t
The different types of action button in Home Screen.
@ SOFT_HOME_ACTION
White button, more for extended features.
@ STRONG_HOME_ACTION
Black button, implicating the main action of the App.
void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseSpinner(const char *text)
void nbgl_useCaseConfirm(const char *message, const char *subMessage, const char *confirmText, const char *rejectText, nbgl_callback_t callback)
void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *rejectText, nbgl_callback_t continueCallback, nbgl_callback_t rejectCallback)
DEPRECATED void nbgl_useCaseHomeExt(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, bool withSettings, const char *actionButtonText, nbgl_callback_t actionCallback, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback)
void nbgl_useCaseKeypadDigits(const char *title, uint8_t minDigits, uint8_t maxDigits, uint8_t backToken, bool shuffled, tune_index_e tuneId, nbgl_pinValidCallback_t validatePinCallback, nbgl_layoutTouchCallback_t actionCallback)
void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t quitCallback)
DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, nbgl_choiceCallback_t callback, const nbgl_contentTagValueList_t *tagValueList)
void nbgl_useCaseGenericConfiguration(const char *title, uint8_t initPage, const nbgl_genericContents_t *contents, nbgl_callback_t quitCallback)
void(* nbgl_actionCallback_t)(uint8_t page)
prototype of function to be called when an page of settings is double-pressed
void nbgl_useCaseReviewStreamingContinueExt(const nbgl_contentTagValueList_t *tagValueList, nbgl_choiceCallback_t choiceCallback, nbgl_callback_t skipCallback)
void nbgl_useCaseReviewBlindSigning(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, const nbgl_tipBox_t *tipBox, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseChoice(const nbgl_icon_details_t *icon, const char *message, const char *subMessage, const char *confirmText, const char *rejectString, nbgl_choiceCallback_t callback)
void nbgl_useCaseGenericReview(const nbgl_genericContents_t *contents, const char *rejectText, nbgl_callback_t rejectCallback)
void nbgl_useCaseRegularReview(uint8_t initPage, uint8_t nbPages, const char *rejectText, nbgl_layoutTouchCallback_t buttonCallback, nbgl_navCallback_t navCallback, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback)
void nbgl_useCaseReviewStreamingBlindSigningStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAdvancedReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, const nbgl_tipBox_t *tipBox, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseReviewStreamingContinue(const nbgl_contentTagValueList_t *tagValueList, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseReviewLight(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
uint8_t nbgl_useCaseGetNbChoicesInPage(uint8_t nbChoices, const nbgl_contentRadioChoice_t *choicesList, uint8_t startIndex, bool withNav)
void nbgl_useCaseReviewStatus(nbgl_reviewStatusType_t reviewStatusType, nbgl_callback_t quitCallback)
void(* nbgl_contentCallback_t)(uint8_t contentIndex, nbgl_content_t *content)
prototype of content navigation callback function
nbgl_reviewStatusType_t
The different types of review status.
@ STATUS_TYPE_TRANSACTION_REJECTED
@ STATUS_TYPE_ADDRESS_REJECTED
@ STATUS_TYPE_TRANSACTION_SIGNED
@ STATUS_TYPE_OPERATION_REJECTED
@ STATUS_TYPE_OPERATION_SIGNED
@ STATUS_TYPE_ADDRESS_VERIFIED
@ STATUS_TYPE_MESSAGE_SIGNED
@ STATUS_TYPE_MESSAGE_REJECTED
bool(* nbgl_navCallback_t)(uint8_t page, nbgl_pageContent_t *content)
prototype of navigation callback function
void nbgl_useCaseAddressReview(const char *address, const nbgl_contentTagValueList_t *additionalTagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
nbgl_opType_t
The different types of operation to review.
@ TYPE_MESSAGE
@ TYPE_TRANSACTION
For operations transferring a coin or taken from an account to another.
@ TYPE_OPERATION
For other types of operation (generic type)
void(* nbgl_pinValidCallback_t)(const uint8_t *content, uint8_t page)
prototype of pin validation callback function
uint8_t nbgl_useCaseGetNbSwitchesInPage(uint8_t nbSwitches, const nbgl_contentSwitchesList_t *switchesList, uint8_t startIndex, bool withNav)
This structure contains data to build a BARS_LIST content.
Definition: nbgl_content.h:306
This structure contains data to build a INFOS_LIST content.
Definition: nbgl_content.h:268
This structure contains data to build a centered info + long press button content.
Definition: nbgl_content.h:94
This structure contains a list of names to build a list of radio buttons (on the right part of screen...
Definition: nbgl_content.h:286
This structure contains a list of [tag,value] pairs.
Definition: nbgl_content.h:185
This structure contains data to build a content.
Definition: nbgl_content.h:374
uint8_t nbContents
number of contents
const nbgl_content_t * contentsList
array of nbgl_content_t (nbContents items).
nbgl_contentCallback_t contentGetterCallback
function to call to retrieve a given content
Structure describing the action button in Home Screen.
const nbgl_icon_details_t * icon
icon to use in action button in Home page
nbgl_callback_t callback
function to call when action button is touched in Home page
const char * text
text to use in action button in Home page
nbgl_homeActionStyle_t style
style of action button
This structure contains data to build a SWITCHES_LIST content.
Definition: nbgl_content.h:260
Structure containing all specific information when creating a NBGL step.
Definition: nbgl_flow.h:43
The necessary parameters to build a tip-box in first review page and the modal if this tip box is tou...
const nbgl_contentInfoList_t infos
infos pairs displayed in modal.
const char * modalTitle
title given to modal window displayed when tip-box is touched
const char * text
text of the tip-box
nbgl_contentType_t type
type of page content in the following union
const nbgl_icon_details_t * icon
icon of the tip-box
unsigned char uint8_t
Definition: usbd_conf.h:53