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:
Sat Jun 12 06:01:50 2010 +0000
Revision:
0:e614f7875b60

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iva2k 0:e614f7875b60 1 /*****************************************************************************
iva2k 0:e614f7875b60 2 * randm.h - Random number generator header file.
iva2k 0:e614f7875b60 3 *
iva2k 0:e614f7875b60 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
iva2k 0:e614f7875b60 5 * Copyright (c) 1998 Global Election Systems Inc.
iva2k 0:e614f7875b60 6 *
iva2k 0:e614f7875b60 7 * The authors hereby grant permission to use, copy, modify, distribute,
iva2k 0:e614f7875b60 8 * and license this software and its documentation for any purpose, provided
iva2k 0:e614f7875b60 9 * that existing copyright notices are retained in all copies and that this
iva2k 0:e614f7875b60 10 * notice and the following disclaimer are included verbatim in any
iva2k 0:e614f7875b60 11 * distributions. No written agreement, license, or royalty fee is required
iva2k 0:e614f7875b60 12 * for any of the authorized uses.
iva2k 0:e614f7875b60 13 *
iva2k 0:e614f7875b60 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
iva2k 0:e614f7875b60 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
iva2k 0:e614f7875b60 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
iva2k 0:e614f7875b60 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
iva2k 0:e614f7875b60 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
iva2k 0:e614f7875b60 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
iva2k 0:e614f7875b60 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
iva2k 0:e614f7875b60 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
iva2k 0:e614f7875b60 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
iva2k 0:e614f7875b60 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
iva2k 0:e614f7875b60 24 *
iva2k 0:e614f7875b60 25 ******************************************************************************
iva2k 0:e614f7875b60 26 * REVISION HISTORY
iva2k 0:e614f7875b60 27 *
iva2k 0:e614f7875b60 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
iva2k 0:e614f7875b60 29 * Ported to lwIP.
iva2k 0:e614f7875b60 30 * 98-05-29 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
iva2k 0:e614f7875b60 31 * Extracted from avos.
iva2k 0:e614f7875b60 32 *****************************************************************************/
iva2k 0:e614f7875b60 33
iva2k 0:e614f7875b60 34 #ifndef RANDM_H
iva2k 0:e614f7875b60 35 #define RANDM_H
iva2k 0:e614f7875b60 36
iva2k 0:e614f7875b60 37 /***********************
iva2k 0:e614f7875b60 38 *** PUBLIC FUNCTIONS ***
iva2k 0:e614f7875b60 39 ***********************/
iva2k 0:e614f7875b60 40 /*
iva2k 0:e614f7875b60 41 * Initialize the random number generator.
iva2k 0:e614f7875b60 42 */
iva2k 0:e614f7875b60 43 void avRandomInit(void);
iva2k 0:e614f7875b60 44
iva2k 0:e614f7875b60 45 /*
iva2k 0:e614f7875b60 46 * Churn the randomness pool on a random event. Call this early and often
iva2k 0:e614f7875b60 47 * on random and semi-random system events to build randomness in time for
iva2k 0:e614f7875b60 48 * usage. For randomly timed events, pass a null pointer and a zero length
iva2k 0:e614f7875b60 49 * and this will use the system timer and other sources to add randomness.
iva2k 0:e614f7875b60 50 * If new random data is available, pass a pointer to that and it will be
iva2k 0:e614f7875b60 51 * included.
iva2k 0:e614f7875b60 52 */
iva2k 0:e614f7875b60 53 void avChurnRand(char *randData, u32_t randLen);
iva2k 0:e614f7875b60 54
iva2k 0:e614f7875b60 55 /*
iva2k 0:e614f7875b60 56 * Randomize our random seed value. To be called for truely random events
iva2k 0:e614f7875b60 57 * such as user operations and network traffic.
iva2k 0:e614f7875b60 58 */
iva2k 0:e614f7875b60 59 #if MD5_SUPPORT
iva2k 0:e614f7875b60 60 #define avRandomize() avChurnRand(NULL, 0)
iva2k 0:e614f7875b60 61 #else /* MD5_SUPPORT */
iva2k 0:e614f7875b60 62 void avRandomize(void);
iva2k 0:e614f7875b60 63 #endif /* MD5_SUPPORT */
iva2k 0:e614f7875b60 64
iva2k 0:e614f7875b60 65 /*
iva2k 0:e614f7875b60 66 * Use the random pool to generate random data. This degrades to pseudo
iva2k 0:e614f7875b60 67 * random when used faster than randomness is supplied using churnRand().
iva2k 0:e614f7875b60 68 * Thus it's important to make sure that the results of this are not
iva2k 0:e614f7875b60 69 * published directly because one could predict the next result to at
iva2k 0:e614f7875b60 70 * least some degree. Also, it's important to get a good seed before
iva2k 0:e614f7875b60 71 * the first use.
iva2k 0:e614f7875b60 72 */
iva2k 0:e614f7875b60 73 void avGenRand(char *buf, u32_t bufLen);
iva2k 0:e614f7875b60 74
iva2k 0:e614f7875b60 75 /*
iva2k 0:e614f7875b60 76 * Return a new random number.
iva2k 0:e614f7875b60 77 */
iva2k 0:e614f7875b60 78 u32_t avRandom(void);
iva2k 0:e614f7875b60 79
iva2k 0:e614f7875b60 80
iva2k 0:e614f7875b60 81 #endif /* RANDM_H */