 
 void sendUdpPacket(const byte * const data, int len)
 {
-  DEBUG_PRINTDATA(2, "Sending UDP packet, len=%d\n", len);
-  DEBUG_PRINTARRAY(2, data, len)
-  DEBUG_PRINT(2, "\n");
+#ifdef ENABLE_DEBUG
+  sprintf(debugBuf, "Sending UDP packet to %d.%d.%d.%d:", TARGET_IP);
+  DEBUG_PRINT(2, debugBuf);
+  DEBUG_PRINTDATA(2, "%d", TARGET_PORT);
+  DEBUG_PRINTDATA(2, ", len=%d, ", len);
+  DEBUG_PRINT(1, "data out: ");
+  DEBUG_PRINTARRAY(1, data, len)
+  DEBUG_PRINT(1, "\n");
+#endif
 
   udp.beginPacket(targetIp, TARGET_PORT);
   udp.write(data, len);
-  udp.endPacket();
-}
+  int retval = udp.endPacket();
+  DEBUG_PRINTDATA(3, "UDP packet sent %s\n", retval == 0 ? "failed" : "succeed");
+}


void debugPrint(char* data)
{
  if (ethernetInitialized)
  {
    udp.beginPacket(targetIp, TARGER_DEBUG_PORT);
    udp.write(data);
    udp.endPacket();
  }

#ifdef PRODINO_BOARD
  Serial.print(data);

#define DEBUG_BUFFER_SIZE       80

#ifdef ENABLE_DEBUG
 #define DEBUG_PRINT(level, message) if (verbose >= level) { debugPrint(message); }
 #define DEBUG_PRINTDATA(level, message, data) if (verbose >= level) { sprintf(debugBuf, message, data); debugPrint(debugBuf); }
 #define DEBUG_PRINTARRAY(level, data, len) if (verbose >= level) { for (int i = 0; i < len; i++) { sprintf(debugBuf, "%02X", data[i]); debugPrint(debugBuf); }}
#else
 #define DEBUG_PRINT(level, message)
 #define DEBUG_PRINTDATA(level, message, data)
 #define DEBUG_PRINTARRAY(level, data, len)
#endif

#ifdef ENABLE_DEBUG
