Example program with HTTPServer and sensor data streaming over TCPSockets, using Donatien Garnier's Net APIs and services code on top of LWIP. Files StreamServer.h and .cpp encapsulate streaming over TCPSockets. Broadcast is done by sendToAll(), and all incoming data is echoed back to the client. Echo code can be replaced with some remote control of the streaming interface. See main() that shows how to periodically send some data to all subscribed clients. To subscribe, a client should open a socket at <mbed_ip> port 123. I used few lines in TCL code to set up a quick sink for the data. HTTP files are served on port 80 concurrently to the streaming.

Dependencies:   mbed

Committer:
iva2k
Date:
Mon Jun 14 03:24:33 2010 +0000
Revision:
1:3ee499525aa5
Parent:
0:e614f7875b60

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iva2k 0:e614f7875b60 1 /*
iva2k 0:e614f7875b60 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
iva2k 0:e614f7875b60 3 * All rights reserved.
iva2k 0:e614f7875b60 4 *
iva2k 0:e614f7875b60 5 * Redistribution and use in source and binary forms, with or without modification,
iva2k 0:e614f7875b60 6 * are permitted provided that the following conditions are met:
iva2k 0:e614f7875b60 7 *
iva2k 0:e614f7875b60 8 * 1. Redistributions of source code must retain the above copyright notice,
iva2k 0:e614f7875b60 9 * this list of conditions and the following disclaimer.
iva2k 0:e614f7875b60 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
iva2k 0:e614f7875b60 11 * this list of conditions and the following disclaimer in the documentation
iva2k 0:e614f7875b60 12 * and/or other materials provided with the distribution.
iva2k 0:e614f7875b60 13 * 3. The name of the author may not be used to endorse or promote products
iva2k 0:e614f7875b60 14 * derived from this software without specific prior written permission.
iva2k 0:e614f7875b60 15 *
iva2k 0:e614f7875b60 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
iva2k 0:e614f7875b60 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
iva2k 0:e614f7875b60 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
iva2k 0:e614f7875b60 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
iva2k 0:e614f7875b60 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
iva2k 0:e614f7875b60 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
iva2k 0:e614f7875b60 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
iva2k 0:e614f7875b60 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
iva2k 0:e614f7875b60 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
iva2k 0:e614f7875b60 25 * OF SUCH DAMAGE.
iva2k 0:e614f7875b60 26 *
iva2k 0:e614f7875b60 27 * This file is part of the lwIP TCP/IP stack.
iva2k 0:e614f7875b60 28 *
iva2k 0:e614f7875b60 29 * Author: Adam Dunkels <adam@sics.se>
iva2k 0:e614f7875b60 30 *
iva2k 0:e614f7875b60 31 */
iva2k 0:e614f7875b60 32 #ifndef __LWIP_DEBUG_H__
iva2k 0:e614f7875b60 33 #define __LWIP_DEBUG_H__
iva2k 0:e614f7875b60 34
iva2k 0:e614f7875b60 35 #include "lwip/arch.h"
iva2k 0:e614f7875b60 36
iva2k 0:e614f7875b60 37 /** lower two bits indicate debug level
iva2k 0:e614f7875b60 38 * - 0 all
iva2k 0:e614f7875b60 39 * - 1 warning
iva2k 0:e614f7875b60 40 * - 2 serious
iva2k 0:e614f7875b60 41 * - 3 severe
iva2k 0:e614f7875b60 42 */
iva2k 0:e614f7875b60 43 #define LWIP_DBG_LEVEL_ALL 0x00
iva2k 0:e614f7875b60 44 #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */
iva2k 0:e614f7875b60 45 #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
iva2k 0:e614f7875b60 46 #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
iva2k 0:e614f7875b60 47 #define LWIP_DBG_LEVEL_SEVERE 0x03
iva2k 0:e614f7875b60 48 #define LWIP_DBG_MASK_LEVEL 0x03
iva2k 0:e614f7875b60 49
iva2k 0:e614f7875b60 50 /** flag for LWIP_DEBUGF to enable that debug message */
iva2k 0:e614f7875b60 51 #define LWIP_DBG_ON 0x80U
iva2k 0:e614f7875b60 52 /** flag for LWIP_DEBUGF to disable that debug message */
iva2k 0:e614f7875b60 53 #define LWIP_DBG_OFF 0x00U
iva2k 0:e614f7875b60 54
iva2k 0:e614f7875b60 55 /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
iva2k 0:e614f7875b60 56 #define LWIP_DBG_TRACE 0x40U
iva2k 0:e614f7875b60 57 /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
iva2k 0:e614f7875b60 58 #define LWIP_DBG_STATE 0x20U
iva2k 0:e614f7875b60 59 /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
iva2k 0:e614f7875b60 60 #define LWIP_DBG_FRESH 0x10U
iva2k 0:e614f7875b60 61 /** flag for LWIP_DEBUGF to halt after printing this debug message */
iva2k 0:e614f7875b60 62 #define LWIP_DBG_HALT 0x08U
iva2k 0:e614f7875b60 63
iva2k 0:e614f7875b60 64 #ifndef LWIP_NOASSERT
iva2k 0:e614f7875b60 65 #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \
iva2k 1:3ee499525aa5 66 LWIP_PLATFORM_ASSERT(message "\r\n"); } while(0)
iva2k 0:e614f7875b60 67 #else /* LWIP_NOASSERT */
iva2k 0:e614f7875b60 68 #define LWIP_ASSERT(message, assertion)
iva2k 0:e614f7875b60 69 #endif /* LWIP_NOASSERT */
iva2k 0:e614f7875b60 70
iva2k 0:e614f7875b60 71 /** if "expression" isn't true, then print "message" and execute "handler" expression */
iva2k 0:e614f7875b60 72 #ifndef LWIP_ERROR
iva2k 0:e614f7875b60 73 #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
iva2k 1:3ee499525aa5 74 LWIP_PLATFORM_ASSERT(message "\r\n"); handler;}} while(0)
iva2k 0:e614f7875b60 75 #endif /* LWIP_ERROR */
iva2k 0:e614f7875b60 76
iva2k 0:e614f7875b60 77 #ifdef LWIP_DEBUG
iva2k 0:e614f7875b60 78 /** print debug message only if debug message type is enabled...
iva2k 0:e614f7875b60 79 * AND is of correct type AND is at least LWIP_DBG_LEVEL
iva2k 0:e614f7875b60 80 */
iva2k 0:e614f7875b60 81 #define LWIP_DEBUGF(debug, message) do { \
iva2k 0:e614f7875b60 82 if ( \
iva2k 0:e614f7875b60 83 ((debug) & LWIP_DBG_ON) && \
iva2k 0:e614f7875b60 84 ((debug) & LWIP_DBG_TYPES_ON) && \
iva2k 0:e614f7875b60 85 ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
iva2k 0:e614f7875b60 86 LWIP_PLATFORM_DIAG(message); \
iva2k 0:e614f7875b60 87 if ((debug) & LWIP_DBG_HALT) { \
iva2k 0:e614f7875b60 88 while(1); \
iva2k 0:e614f7875b60 89 } \
iva2k 0:e614f7875b60 90 } \
iva2k 0:e614f7875b60 91 } while(0)
iva2k 0:e614f7875b60 92
iva2k 0:e614f7875b60 93 #else /* LWIP_DEBUG */
iva2k 0:e614f7875b60 94 #define LWIP_DEBUGF(debug, message)
iva2k 0:e614f7875b60 95 #endif /* LWIP_DEBUG */
iva2k 0:e614f7875b60 96
iva2k 0:e614f7875b60 97 #endif /* __LWIP_DEBUG_H__ */
iva2k 0:e614f7875b60 98