Closed refi93 closed 5 years ago
a simple workaround could be replacing for Nano X the set_timer
calls with
UX_CALLBACK_SET_INTERVAL(HEADLESS_DELAY)
The UX_CALLBACK_SET_INTERVAL would set the internal G_ux.stack[].ticker_value
to a value greater than zero, which would trigger the "autoconfirm" callback internally set by UX_STEP_CB
and UX_STEP_NOCB
, but I'm not sure if this is desired since it would not call our own headless callbacks and therefore skip the asserts we have there. But I guess the additional asserts in the headless callbacks won't be really needed if we rely on the integrity of the SDK.
We decided to go with an alternate fix implementation
I found out, that the
UX_STEP_CB
macro used in our confirm screens actually sets the internal G_ux.stack[0].ticker_callback, which ends up overriding our callback in theUX_TICKER_EVENT
macro. The thing is thatUX_STEP_CB
sets that callback with timeout 0ms (ux_flow_engine, line 125, sdk nanox dev6), so it isn't actually executed, so neither it isn't cleared from the stack (not sure if it is a bug or feature).The newly introduced
UX_STEP_TIMEOUT
macro does not seem to suit well our needs since it seems to be meant as a separate ux flow with autoconfirm after a certain timeout, it cannot override the behavior of an existing flow like we want in headless mode.UX_STEP_TIMEOUT
is therefore effectively disabled by this PR and I added to the code a warning about that. Other functions in the SDK do not seem to actually use theG_ux.stack[].ticker_callback
so we should be ok.I believe that we can refactor headless mode to be impelemented through
UX_STEP_TIMEOUT
by "ifdefing" all the flows we have to beUX_STEP_TIMEOUT
in headless mode, but it makes sense to postpone that until Nano S UI API is aligned with Nano X.