Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed
debug.h
00001 /* 00002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00025 * OF SUCH DAMAGE. 00026 * 00027 * This file is part of the lwIP TCP/IP stack. 00028 * 00029 * Author: Adam Dunkels <adam@sics.se> 00030 * 00031 */ 00032 #ifndef __LWIP_DEBUG_H__ 00033 #define __LWIP_DEBUG_H__ 00034 00035 #include "lwip/arch.h" 00036 00037 /** lower two bits indicate debug level 00038 * - 0 off 00039 * - 1 warning 00040 * - 2 serious 00041 * - 3 severe 00042 */ 00043 #define LWIP_DBG_LEVEL_OFF 0x00 00044 #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 00045 #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 00046 #define LWIP_DBG_LEVEL_SEVERE 0x03 00047 #define LWIP_DBG_MASK_LEVEL 0x03 00048 00049 /** flag for LWIP_DEBUGF to enable that debug message */ 00050 #define LWIP_DBG_ON 0x80U 00051 /** flag for LWIP_DEBUGF to disable that debug message */ 00052 #define LWIP_DBG_OFF 0x00U 00053 00054 /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 00055 #define LWIP_DBG_TRACE 0x40U 00056 /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 00057 #define LWIP_DBG_STATE 0x20U 00058 /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 00059 #define LWIP_DBG_FRESH 0x10U 00060 /** flag for LWIP_DEBUGF to halt after printing this debug message */ 00061 #define LWIP_DBG_HALT 0x08U 00062 00063 #ifndef LWIP_NOASSERT 00064 #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 00065 LWIP_PLATFORM_ASSERT(message); } while(0) 00066 #else /* LWIP_NOASSERT */ 00067 #define LWIP_ASSERT(message, assertion) 00068 #endif /* LWIP_NOASSERT */ 00069 00070 /** if "expression" isn't true, then print "message" and execute "handler" expression */ 00071 #ifndef LWIP_ERROR 00072 #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 00073 LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 00074 #endif /* LWIP_ERROR */ 00075 00076 #ifdef LWIP_DEBUG 00077 /** print debug message only if debug message type is enabled... 00078 * AND is of correct type AND is at least LWIP_DBG_LEVEL 00079 */ 00080 #define LWIP_DEBUGF(debug, message) do { \ 00081 if ( \ 00082 ((debug) & LWIP_DBG_ON) && \ 00083 ((debug) & LWIP_DBG_TYPES_ON) && \ 00084 ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 00085 LWIP_PLATFORM_DIAG(message); \ 00086 if ((debug) & LWIP_DBG_HALT) { \ 00087 while(1); \ 00088 } \ 00089 } \ 00090 } while(0) 00091 00092 #else /* LWIP_DEBUG */ 00093 #define LWIP_DEBUGF(debug, message) 00094 #endif /* LWIP_DEBUG */ 00095 00096 #endif /* __LWIP_DEBUG_H__ */ 00097
Generated on Tue Jul 12 2022 19:17:23 by 1.7.2