gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-mdb] 88/93: log levels


From: gnunet
Subject: [taler-taler-mdb] 88/93: log levels
Date: Mon, 18 Nov 2019 21:13:51 +0100

This is an automated email from the git hooks/post-receive script.

marco-boss pushed a commit to branch master
in repository taler-mdb.

commit ab67d247e12bf81bc683670052357f40a4d6971e
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Nov 16 11:30:21 2019 +0100

    log levels
---
 src/main.c | 81 +++++++++++++++++++++++++-------------------------------------
 1 file changed, 32 insertions(+), 49 deletions(-)

diff --git a/src/main.c b/src/main.c
index a6bd1af..69436ef 100644
--- a/src/main.c
+++ b/src/main.c
@@ -82,6 +82,11 @@ along with
  */
 #define APDU_NOT_FOUND "\x6a\x82"
 
+/* upper and lower bounds for mifare targets uid length */
+#define UID_LEN_UPPER 7
+#define UID_LEN_LOWER 4
+
+
 /* curl auth header */
 #define SNACK_CURL_AUTH_HEADER "Authorization"
 
@@ -136,6 +141,7 @@ struct PaymentActivity
   int wallet_has_uri;
 };
 
+
 struct Display
 {
   int devicefd;
@@ -197,6 +203,8 @@ show_qrcode (const char *uri)
   size_t xOff;
   size_t yOff;
 
+  if (0 < qrDisplay.devicefd)
+    return; /* no display, no dice */
   qri = QRinput_new2 (0, QR_ECLEVEL_L);
   if (NULL == qri)
   {
@@ -264,28 +272,9 @@ show_qrcode (const char *uri)
   QRinput_free (qri);
 }
 
-
 #endif
 
 
-static void
-SNACK_print_hex_info (const char*message,
-                      const uint8_t *hexArray,
-                      size_t sizeHex)
-{
-  char hex[5] = {""};
-  char str[64] = {""};
-
-  for (unsigned int i = 0; i < sizeHex; ++i)
-  {
-    sprintf (hex, "%.2x ", hexArray[i]);
-    strcat (str, hex);
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "%s: %s\n", message, str);
-
-}
-
-
 static void
 cleanup_payment (struct PaymentActivity *pa)
 {
@@ -302,18 +291,20 @@ cleanup_payment (struct PaymentActivity *pa)
     GNUNET_SCHEDULER_cancel (pa->task);
   if (NULL != pa->delay_task)
     GNUNET_SCHEDULER_cancel (pa->delay_task);
-  GNUNET_free_non_null (pa->taler_pay_uri);
-  GNUNET_free_non_null (pa->order_id);
-  GNUNET_free (pa);
-
+  if (NULL != pa->taler_pay_uri)
+  {
 #if HAVE_QRENCODE_H
-  if (NULL != qrDisplay.memory)
-    memset (qrDisplay.memory,
-            0xFF,
-            qrDisplay.var_info.xres * qrDisplay.var_info.yres
-            * sizeof (uint16_t));
-  /* FIXME: dimm background light of display */
+    if (NULL != qrDisplay.memory)
+      memset (qrDisplay.memory,
+              0xFF,
+              qrDisplay.var_info.xres * qrDisplay.var_info.yres
+              * sizeof (uint16_t));
+    /* FIXME: dimm background light of display */
 #endif
+    GNUNET_free (pa->taler_pay_uri);
+  }
+  GNUNET_free_non_null (pa->order_id);
+  GNUNET_free (pa);
 }
 
 
@@ -355,6 +346,7 @@ shutdown_task (void *cls)
     /* free the display data  */
     munmap (qrDisplay.memory,
             qrDisplay.fix_info.smem_len);
+    qrDisplay.memory = NULL;
     /* reset original state */
     if (0 > ioctl (qrDisplay.devicefd,
                    FBIOPUT_VSCREENINFO,
@@ -363,9 +355,9 @@ shutdown_task (void *cls)
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "failed to reset originial display state\n");
     }
-
     /* close device */
     close (qrDisplay.devicefd);
+    qrDisplay.devicefd = -1;
   }
   if (NULL != products)
   {
@@ -416,9 +408,8 @@ wallet_transmit_uri (void *cls)
                                           sizeof(response),
                                           NFC_TIMEOUT))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Failed to send command\n");
-    /* Has this to be an error ? */
     pa->task = GNUNET_SCHEDULER_add_now (&connect_target,
                                          pa);
     return;
@@ -465,7 +456,7 @@ wallet_select_aid (void *cls)
                                           sizeof (response),
                                           NFC_TIMEOUT))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                                     
/* Has this to be an error ? */
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Failed to transceive with NFC app, trying to find another NFC 
client\n");
     pa->task = GNUNET_SCHEDULER_add_now (&connect_target,
                                          pa);
@@ -501,42 +492,34 @@ wallet_select_aid (void *cls)
 }
 
 
-/* upper and lower bounds for mifare targets uid length */
-#define UID_LEN_UPPER 7
-#define UID_LEN_LOWER 4
-
-
 static void
 connect_target (void *cls)
 {
   struct PaymentActivity *pa = cls;
-  const nfc_modulation nmMifare[] = { {
-                                        .nmt = NMT_ISO14443A,
-                                        .nbr = NBR_212,
-                                      } };
+  const nfc_modulation nmMifare = {
+    .nmt = NMT_ISO14443A,
+    .nbr = NBR_212,
+  };
 
   pa->task = NULL;
   pa->nt.nti.nai.szUidLen = 0;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Trying to find NFC client\n");
   if (0 > nfc_initiator_poll_target (pa->pnd,
-                                     nmMifare,
+                                     &nmMifare,
                                      1,
                                      0x01,
                                      0x01,
                                      &pa->nt))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,                   /* Has this to be 
an error ? */
-                "Failed to connect to nfc target\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Failed to connect to NFC target\n");
   }
   else if ( (pa->nt.nti.nai.szUidLen > UID_LEN_UPPER) ||
             (pa->nt.nti.nai.szUidLen < UID_LEN_LOWER) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Failed to connect, wrong NFC modulation\n");
-    SNACK_print_hex_info ("UID",
-                          pa->nt.nti.nai.abtUid,
-                          pa->nt.nti.nai.szUidLen);
   }
   else
   {
@@ -662,10 +645,10 @@ check_payment_cb (void *cls,
                 "Trying to talk to wallet to give it pay URI `%s'\n",
                 taler_pay_uri);
     GNUNET_assert (NULL == pa->pnd);
+    pa->taler_pay_uri = GNUNET_strdup (taler_pay_uri);
 #if HAVE_QRENCODE_H
     show_qrcode (taler_pay_uri);
 #endif
-    pa->taler_pay_uri = GNUNET_strdup (taler_pay_uri);
     pa->task = GNUNET_SCHEDULER_add_now (&connect_nfc,
                                          pa);
   }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]