cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
Loading...
Searching...
No Matches
ui.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: LGPL-3.0-or-later
3 * Copyright (c) 2026 Cryptnox SA
4 */
5
12
13#ifndef UI_H
14#define UI_H
15
16/******************************************************************
17 * 1. Included files
18 ******************************************************************/
19
20#include <stdint.h>
21#include <stdbool.h>
22#include <stddef.h>
23
24#include "net.h" /* net_wifi_ap_t for the network picker */
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/******************************************************************
31 * 2. Types
32 ******************************************************************/
33
53
92
106
118
128typedef void (*ui_event_cb_t)(ui_event_t event, uint64_t payload);
129
130/******************************************************************
131 * 3. Public API
132 ******************************************************************/
133
139void ui_init(ui_event_cb_t cb);
140
142void ui_show_splash(void);
143
145void ui_show_amount_entry(void);
146
156void ui_show_confirm(uint64_t amount_units, const char *dest_addr,
157 const char *fee);
158
166void ui_show_tx_status(ui_tx_state_t state, const char *info);
167
178void ui_set_tx_info(const char *info);
179
190size_t ui_take_pin(char *out, size_t n);
191
201void ui_show_wifi_list(const net_wifi_ap_t *aps, uint16_t n, const char *note);
202
210void ui_show_boot_error(ui_boot_err_t kind, const char *detail);
211
217void ui_set_addresses(const char *token_contract, const char *dest_addr);
218
227void ui_refresh_addresses(void);
228
235void ui_refresh_addresses_for(uint8_t chain);
236
243void ui_show_wifi_connecting(const char *ssid);
244
254void ui_set_boot_status(const char *step);
255
267void ui_fees_changed(void);
268
279void ui_clock_changed(void);
280
291void ui_show_welcome(const char *sub);
292
300void ui_show_admin_set(void);
301
313size_t ui_take_wifi_creds(char *ssid, size_t ssid_n, char *pass, size_t pass_n);
314
325void ui_stage_wifi_creds(const char *ssid, const char *pass);
326
338void ui_show_prov(int step);
339
348void ui_show_prov_confirm(void);
349
357void ui_show_prov_auth(void);
358
366void ui_show_card_pin(void);
367
381void ui_set_prov_note(const char *msg);
382
391void ui_show_card_wait(const char *note);
392
402void ui_show_ota_confirm(void);
403
404#ifdef __cplusplus
405}
406#endif
407
408#endif // UI_H
Network bring-up: Wi-Fi station (init/scan/connect/RSSI) and SNTP time sync. No application-protocol ...
A scanned access point (subset of fields the UI needs).
Definition net.h:33
void ui_set_prov_note(const char *msg)
Put a failure line on the setup screen, in red under the step title.
Definition ui.cpp:880
void ui_show_prov(int step)
Show the setup screen: QR code, AP name and passphrase.
Definition ui.cpp:850
void ui_show_confirm(uint64_t amount_units, const char *dest_addr, const char *fee)
Switch to the confirm screen.
Definition ui.cpp:718
void ui_show_prov_auth(void)
Demand the admin code so a browser can be authorised.
Definition ui.cpp:861
void ui_show_welcome(const char *sub)
Greet the operator at the start of first-run setup, or after an update.
Definition ui.cpp:807
void ui_set_boot_status(const char *step)
Set the one-line progress note on the splash screen.
Definition ui.cpp:776
void ui_show_wifi_list(const net_wifi_ap_t *aps, uint16_t n, const char *note)
Show the scanned Wi-Fi networks for the user to pick from.
Definition ui.cpp:747
ui_screen_t
Top-level screens of the payment flow.
Definition ui.h:35
@ UI_SCREEN_TOUCH_CAL
Definition ui.h:51
@ UI_SCREEN_AMOUNT
Definition ui.h:37
@ UI_SCREEN_BOOT_ERROR
Definition ui.h:45
@ UI_SCREEN_WIFI_PASS
Definition ui.h:41
@ UI_SCREEN_ADMIN_SET
Definition ui.h:46
@ UI_SCREEN_SETTINGS
Definition ui.h:43
@ UI_SCREEN_ADMIN_UNLOCK
Definition ui.h:47
@ UI_SCREEN_WIFI_LIST
Definition ui.h:40
@ UI_SCREEN_SPLASH
Definition ui.h:36
@ UI_SCREEN_CONFIRM
Definition ui.h:38
@ UI_SCREEN_TX_STATUS
Definition ui.h:44
@ UI_SCREEN_PROV
Definition ui.h:49
@ UI_SCREEN_WELCOME
Definition ui.h:48
@ UI_SCREEN_PIN
Definition ui.h:39
@ UI_SCREEN_CARD_WAIT
Definition ui.h:50
@ UI_SCREEN_WIFI_CONNECTING
Definition ui.h:42
void ui_show_card_pin(void)
Ask for the card PIN before reading an address off a Cryptnox card.
Definition ui.cpp:873
ui_tx_state_t
States shown on the transaction-status screen.
Definition ui.h:94
@ UI_TX_STATE_SIGNING
Definition ui.h:97
@ UI_TX_STATE_SENDING
Definition ui.h:98
@ UI_TX_STATE_UNCONFIRMED
Definition ui.h:102
@ UI_TX_STATE_CONFIRMING
Definition ui.h:99
@ UI_TX_STATE_PLACE_CARD
Definition ui.h:95
@ UI_TX_STATE_DONE
Definition ui.h:100
@ UI_TX_STATE_FAILED
Definition ui.h:101
@ UI_TX_STATE_PROCESSING
Definition ui.h:96
void ui_show_ota_confirm(void)
Raise the modal that asks the operator to accept a firmware image the update page has uploaded,...
Definition ui.cpp:893
void ui_refresh_addresses_for(uint8_t chain)
Same, for any chain (a pos_chain_t) rather than the one sales use.
Definition pay.cpp:155
void ui_init(ui_event_cb_t cb)
Initialise display + touch and start the UI task.
Definition ui.cpp:696
size_t ui_take_wifi_creds(char *ssid, size_t ssid_n, char *pass, size_t pass_n)
Fetch the selected SSID + entered password and wipe the UI's copy.
Definition ui.cpp:827
void ui_set_addresses(const char *token_contract, const char *dest_addr)
Provide the token contract and destination addresses for the confirm screen and the settings "Tx" tab...
Definition ui.cpp:764
void ui_fees_changed(void)
Note that the stored gas caps have changed, so the Tx tab can catch up.
Definition ui.cpp:783
void ui_show_tx_status(ui_tx_state_t state, const char *info)
Switch to the transaction-status screen.
Definition ui.cpp:898
void ui_stage_wifi_creds(const char *ssid, const char *pass)
Load credentials into the same handoff buffers the picker fills.
Definition ui.cpp:842
void ui_show_amount_entry(void)
Switch to the amount-entry screen (forces a value redraw).
Definition ui.cpp:711
void ui_show_prov_confirm(void)
Raise the modal that asks the operator to accept a value a browser proposed, reading the pending prop...
Definition ui.cpp:856
void ui_refresh_addresses(void)
Implemented by main: repoint those two rows at the selected chain.
Definition pay.cpp:170
ui_event_t
Events emitted by the UI task towards the main task.
Definition ui.h:55
@ UI_EVENT_CONFIRM_CANCEL
Definition ui.h:58
@ UI_EVENT_PIN_ENTERED
Definition ui.h:59
@ UI_EVENT_OTA_STAGED
Definition ui.h:82
@ UI_EVENT_PROV_AUTH
Definition ui.h:66
@ UI_EVENT_CARD_PIN
Definition ui.h:80
@ UI_EVENT_WIFI_TRY
Definition ui.h:61
@ UI_EVENT_ADMIN_SET
Definition ui.h:64
@ UI_EVENT_PROV_VALUE_NO
Definition ui.h:71
@ UI_EVENT_WELCOME_DONE
Definition ui.h:65
@ UI_EVENT_PROV_FINISH
Definition ui.h:79
@ UI_EVENT_AMOUNT_CONFIRMED
Definition ui.h:56
@ UI_EVENT_WIFI_SCAN
Definition ui.h:60
@ UI_EVENT_PROV_CARD
Definition ui.h:75
@ UI_EVENT_PROV_VALUE
Definition ui.h:68
@ UI_EVENT_PROV_SCAN
Definition ui.h:77
@ UI_EVENT_CONFIRM_OK
Definition ui.h:57
@ UI_EVENT_PROV_NEXT
Definition ui.h:78
@ UI_EVENT_PROV_STOP
Definition ui.h:86
@ UI_EVENT_TX_RETRY
Definition ui.h:62
@ UI_EVENT_PROV_VALUE_SET
Definition ui.h:70
@ UI_EVENT_TX_RECHECK
Definition ui.h:84
ui_boot_err_t
Startup faults shown on UI_SCREEN_BOOT_ERROR.
Definition ui.h:113
@ UI_BOOT_ERR_WALLET
Definition ui.h:115
@ UI_BOOT_ERR_CONFIG
Definition ui.h:116
@ UI_BOOT_ERR_NFC
Definition ui.h:114
void ui_show_admin_set(void)
Run the first-run admin-code creation (enter, then confirm).
Definition ui.cpp:818
void ui_set_tx_info(const char *info)
Replace the transaction screen's info line without rebuilding it.
Definition ui.cpp:910
void ui_show_splash(void)
Switch to the splash screen.
Definition ui.cpp:706
void ui_show_wifi_connecting(const char *ssid)
Show a "Connecting to <ssid>…" screen while main associates.
Definition ui.cpp:770
void ui_show_card_wait(const char *note)
"Hold your card to the reader" while the address is read.
Definition ui.cpp:886
void ui_show_boot_error(ui_boot_err_t kind, const char *detail)
Show a startup fault, naming the cause and what to do about it.
Definition ui.cpp:795
size_t ui_take_pin(char *out, size_t n)
Copy the most recently entered PIN out and wipe the UI's copy.
Definition ui.cpp:733
void ui_clock_changed(void)
Note that the stored UTC offset has changed, so the clock can catch up.
Definition ui.cpp:788
void(* ui_event_cb_t)(ui_event_t event, uint64_t payload)
Callback invoked from the UI task on user interaction.
Definition ui.h:128