cash2ecash

cash2ecash: cash acceptor that issues digital cash (experimental)
Log | Files | Refs | README | LICENSE

commit 5fa872e12240a6691508090341aa692c84ee0327
parent 50793852584caf876ca53915828aa7e92032d70e
Author: Tellenbach Reto <tellr1@bfh.ch>
Date:   Sun,  7 Jun 2026 17:35:42 +0200

[wip] State-logic: show QR code

Diffstat:
Msrc/taler-digitizer.c | 49+++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 45 insertions(+), 4 deletions(-)

diff --git a/src/taler-digitizer.c b/src/taler-digitizer.c @@ -42,6 +42,8 @@ #define FRAMEBUFFER_SIZE 256 #define PATH_QR_SHOW "../ext/QRshow" +#define SCAN_QR_TIMEOUT_SECONDS 100 + /** * Global return value */ @@ -293,7 +295,7 @@ struct DIGITIZER_DisplayContext *display_ctx; static void state_controller_task(void *cls); enum GNUNET_GenericReturnValue -run_qr_show(int showtime,char *wopid_url) +run_qr_show(int showtime, const char *wopid_url) { FILE *fp; //char buffer[FRAMEBUFFER_SIZE]; @@ -466,6 +468,24 @@ on_post_accounts_withdrawal_done(void *cls, return; } + +/** + * Timeout when QR is shown + * SCAN_QR_TIMEOUT_SECONDS without been scanned + * used in the ScanQR state + */ +static void +ScanQR_timeout(void *cls) +{ + TALER_LOG_DEBUG ("Timeout of ScanQR\n"); + + (void) cls; + + state = DIGITIZER_STATE_CANCEL_WITHDRAWAL; + GNUNET_SCHEDULER_add_now(state_controller_task,NULL); + return; +} + /** * @brief Cleanup when no task is scheduled anymore * @@ -946,7 +966,7 @@ static void CreateQR_state_task(void *cls) on_post_accounts_withdrawal_done, NULL)) { - TALER_LOG_ERROR("TALER_BANK_post_accounts_withdrawal\n"); + TALER_LOG_ERROR("TALER_BANK_post_accounts_withdrawal canceled\n"); state = DIGITIZER_STATE_CANCEL_WITHDRAWAL; // give context for non terminal errors! GNUNET_SCHEDULER_add_now(state_controller_task,NULL); @@ -956,6 +976,29 @@ static void CreateQR_state_task(void *cls) } /** + * Show QR state + * show QR code on display + * check for cancle from UI + */ +static void ScanQR_state_task(void *cls) +{ + (void)cls; + struct GNUNET_TIME_Relative delay; + delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,SCAN_QR_TIMEOUT_SECONDS); + if(GNUNET_OK != run_qr_show(SCAN_QR_TIMEOUT_SECONDS, state_ctx->wi.taler_withdraw_uri)) + { + TALER_LOG_ERROR("run_qr_show failed\n"); + state = DIGITIZER_STATE_CANCEL_WITHDRAWAL; + // give context for non terminal errors! + GNUNET_SCHEDULER_add_now(state_controller_task,NULL); + } + + + GNUNET_SCHEDULER_add_delayed(delay,ScanQR_timeout,NULL); + return; +} + +/** * Switch between State tasks */ static void state_controller_task(void *cls) @@ -984,13 +1027,11 @@ static void state_controller_task(void *cls) GNUNET_SCHEDULER_add_now(CreateQR_state_task,NULL); return; } - /* case DIGITIZER_STATE_SCAN_QR: { GNUNET_SCHEDULER_add_now(ScanQR_state_task,NULL); return; } - */ default: {