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.
igmp.h
00001 /* 00002 * Copyright (c) 2002 CITEL Technologies Ltd. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors 00014 * may be used to endorse or promote products derived from this software 00015 * without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE 00021 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00023 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00024 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00027 * SUCH DAMAGE. 00028 * 00029 * This file is a contribution to the lwIP TCP/IP stack. 00030 * The Swedish Institute of Computer Science and Adam Dunkels 00031 * are specifically granted permission to redistribute this 00032 * source code. 00033 */ 00034 00035 #ifndef __LWIP_IGMP_H__ 00036 #define __LWIP_IGMP_H__ 00037 00038 #include "lwip/opt.h" 00039 #include "lwip/ip_addr.h" 00040 #include "lwip/netif.h" 00041 #include "lwip/pbuf.h" 00042 00043 #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 00050 /* IGMP timer */ 00051 #define IGMP_TMR_INTERVAL 100 /* Milliseconds */ 00052 #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) 00053 #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) 00054 00055 /* MAC Filter Actions, these are passed to a netif's 00056 * igmp_mac_filter callback function. */ 00057 #define IGMP_DEL_MAC_FILTER 0 00058 #define IGMP_ADD_MAC_FILTER 1 00059 00060 00061 /** 00062 * igmp group structure - there is 00063 * a list of groups for each interface 00064 * these should really be linked from the interface, but 00065 * if we keep them separate we will not affect the lwip original code 00066 * too much 00067 * 00068 * There will be a group for the all systems group address but this 00069 * will not run the state machine as it is used to kick off reports 00070 * from all the other groups 00071 */ 00072 struct igmp_group { 00073 /** next link */ 00074 struct igmp_group *next; 00075 /** interface on which the group is active */ 00076 struct netif *netif; 00077 /** multicast address */ 00078 ip_addr_t group_address; 00079 /** signifies we were the last person to report */ 00080 u8_t last_reporter_flag; 00081 /** current state of the group */ 00082 u8_t group_state; 00083 /** timer for reporting, negative is OFF */ 00084 u16_t timer; 00085 /** counter of simultaneous uses */ 00086 u8_t use; 00087 }; 00088 00089 /* Prototypes */ 00090 void igmp_init(void); 00091 err_t igmp_start(struct netif *netif); 00092 err_t igmp_stop(struct netif *netif); 00093 void igmp_report_groups(struct netif *netif); 00094 struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); 00095 void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); 00096 err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); 00097 err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); 00098 void igmp_tmr(void); 00099 00100 #ifdef __cplusplus 00101 } 00102 #endif 00103 00104 #endif /* LWIP_IGMP */ 00105 00106 #endif /* __LWIP_IGMP_H__ */
Generated on Tue Jul 12 2022 21:10:25 by 1.7.2