Sebastián Pastor / EtheriosCloudConnector
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.h Source File

debug.h

00001 /*
00002  * Copyright (c) 2013 Digi International Inc.,
00003  * All rights not expressly granted are reserved.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
00007  * You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
00010  * =======================================================================
00011  */
00012 
00013 #if (defined CONNECTOR_DEBUG)
00014 
00015 #define enum_to_case(name)  case name:  result = #name;             break
00016 
00017 void connector_debug_hexvalue(char * label, uint8_t * buff, size_t length)
00018 {
00019     size_t i;
00020 
00021     connector_debug_printf("%s = ", label);
00022     for (i=0; i<length; i++)
00023     {
00024         connector_debug_printf(" %02X", buff[i]);
00025         if (i > 0 && (i % 16) == 0)
00026         {
00027             connector_debug_printf("\n%.*s", (strlen(label)+3), " ");
00028         }
00029     }
00030     connector_debug_printf("\n");
00031 }
00032 
00033 #else
00034 #define connector_debug_hexvalue(label, start, length)
00035 
00036 static void connector_debug_printf(char const * const format, ...)
00037 {
00038     (void) format;
00039 }
00040 
00041 #endif
00042 
00043 #if (defined CONNECTOR_DEBUG)
00044 
00045 static char const * transport_to_string(connector_transport_t const value)
00046 {
00047     char const * result = NULL;
00048     switch (value)
00049     {
00050         #if (defined CONNECTOR_TRANSPORT_TCP)
00051         enum_to_case(connector_transport_tcp);
00052         #endif
00053         #if (defined CONNECTOR_TRANSPORT_UDP)
00054         enum_to_case(connector_transport_udp);
00055         #endif
00056         #if (defined CONNECTOR_TRANSPORT_SMS)
00057         enum_to_case(connector_transport_sms);
00058         #endif
00059         enum_to_case(connector_transport_all);
00060     }
00061     return result;
00062 }
00063 #else
00064 
00065 #define transport_to_string(value)       NULL
00066 #endif
00067 
00068