taler-mdb

GNU Taler Extensions and Integrations
Log | Files | Refs | Submodules | README | LICENSE

commit 98b5626ace51fcd0a2c7b0f35198ff2464e1c51b
parent d83c076899a2cf775360a9c1a65769126087cc0e
Author: Dominik Hofer <dominik.hofer@bfh.ch>
Date:   Fri,  6 Dec 2019 12:02:53 +0100

fixtodos

Diffstat:
Msrc/main.c | 34+++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -25,6 +25,8 @@ along with * TODO: * - comment code (Boss) * - replace remaining MDB magic constants with #defines (Hofer) +* - no warnings for known commands that we do not care about (maybe DEBUG-level logging!) (Hofer) +* - implement cancel confirmation (Hofer) */ #include "config.h" #include <stdio.h> @@ -142,6 +144,16 @@ along with #define VMC_VEND_SUCCESS 0x02 #define VMC_VEND_FAILURE 0x03 #define VMC_VEND_SESSION_COMPLETE 0x04 + +/** + * Commands for the reader (our device). + */ +#define VMC_READER 0x14 +#define VMC_READER_ENABLE 0x01 +#define VMC_READER_CANCEL 0x02 + +#define VMC_REQUEST_ID 0x17 + /** * Out of sequence. */ @@ -158,10 +170,10 @@ along with #define READER_VEND_APPROVE "05" #define READER_VEND_DENIED "06" #define READER_END_SESSION "07" +#define READER_CANCELLED "08" /* Unused reader commands */ #define READER_DISPLAY_REQUEST "02" -#define READER_SESSION_CANCELLED "08" #define READER_SESSION_CANCEL_REQUEST "04" #define READER_REVALUE_APPROVED "0D" #define READER_REVALUE_DENIED "0E" @@ -493,6 +505,11 @@ static struct MdbCommand denyVend; static struct MdbCommand approveVend; /** + * Confirm cancellation by machine. + */ +static struct MdbCommand readerCancelled; + +/** * Terminate session. */ static struct MdbCommand endSession; @@ -1747,7 +1764,7 @@ handle_command (const char *hex, "Received request for configuration via MDB\n"); mdb.cmd = &readerConfigData; break; - case 0x14: + case VMC_READER: { unsigned int subcmd; @@ -1766,11 +1783,15 @@ handle_command (const char *hex, switch (subcmd) { - case 0x01: + case VMC_READER_ENABLE: GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received Reader Enable via MDB\n"); mdb.session_running = GNUNET_NO; break; + case VMC_READER_CANCEL: + mdb.cmd = &readerCancelled; + mdb.session_running = GNUNET_NO; + break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unknown MDB sub-command %X of command %X\n", @@ -1780,6 +1801,10 @@ handle_command (const char *hex, } break; } + case VMC_REQUEST_ID: + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received VMC request ID, no need to handle (done by HW)\n"); + break; case VMC_ACKN: GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received acknowledgement (for command `%s') from MDB\n", @@ -2395,6 +2420,9 @@ main (int argc, approveVend = setup_mdb_cmd ("Approve Vend", READER_VEND_APPROVE, "0001"); + readerCancelled = setup_mdb_cmd ("Confirm cancellation", + READER_CANCELLED, + NULL); denyVend = setup_mdb_cmd ("Deny Vend", READER_VEND_DENIED, NULL);