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 #include "sys_arch.h"
iva2k 0:e614f7875b60 2 #include "mbed.h"
iva2k 0:e614f7875b60 3 //DG 2010
iva2k 0:e614f7875b60 4
iva2k 0:e614f7875b60 5 #ifdef __cplusplus
iva2k 0:e614f7875b60 6 extern "C" {
iva2k 0:e614f7875b60 7 #endif
iva2k 0:e614f7875b60 8
iva2k 0:e614f7875b60 9 #ifdef __COMPLEX_AND_BUGGUY_HANDLING__
iva2k 0:e614f7875b60 10 static Timer* pTmr = NULL;
iva2k 0:e614f7875b60 11
iva2k 0:e614f7875b60 12 void sys_init(void)
iva2k 0:e614f7875b60 13 {
iva2k 0:e614f7875b60 14 //Start Timer
iva2k 0:e614f7875b60 15 pTmr = new Timer();
iva2k 0:e614f7875b60 16 pTmr->start();
iva2k 0:e614f7875b60 17 }
iva2k 0:e614f7875b60 18
iva2k 0:e614f7875b60 19 u32_t sys_jiffies(void) /* since power up. */
iva2k 0:e614f7875b60 20 {
iva2k 0:e614f7875b60 21 return (u32_t) (pTmr->read_ms()/10); //In /10ms units
iva2k 0:e614f7875b60 22 }
iva2k 0:e614f7875b60 23
iva2k 0:e614f7875b60 24 u32_t sys_now(void)
iva2k 0:e614f7875b60 25 {
iva2k 0:e614f7875b60 26 return (u32_t) pTmr->read_ms(); //In /ms units
iva2k 0:e614f7875b60 27 }
iva2k 0:e614f7875b60 28 #elif0
iva2k 0:e614f7875b60 29 void sys_init(void)
iva2k 0:e614f7875b60 30 {
iva2k 0:e614f7875b60 31
iva2k 0:e614f7875b60 32 }
iva2k 0:e614f7875b60 33
iva2k 0:e614f7875b60 34 u32_t sys_jiffies(void) /* since power up. */
iva2k 0:e614f7875b60 35 {
iva2k 0:e614f7875b60 36 static int count = 0;
iva2k 0:e614f7875b60 37 return ++count;
iva2k 0:e614f7875b60 38 }
iva2k 0:e614f7875b60 39
iva2k 0:e614f7875b60 40 u32_t sys_now(void)
iva2k 0:e614f7875b60 41 {
iva2k 0:e614f7875b60 42 return (u32_t) time(NULL);
iva2k 0:e614f7875b60 43 }
iva2k 0:e614f7875b60 44 #else
iva2k 0:e614f7875b60 45 static Timer* pTmr = NULL;
iva2k 0:e614f7875b60 46
iva2k 0:e614f7875b60 47 void sys_init(void)
iva2k 0:e614f7875b60 48 {
iva2k 0:e614f7875b60 49 //Start Timer
iva2k 0:e614f7875b60 50 pTmr = new Timer();
iva2k 0:e614f7875b60 51 pTmr->start();
iva2k 0:e614f7875b60 52 }
iva2k 0:e614f7875b60 53
iva2k 0:e614f7875b60 54 u32_t sys_jiffies(void) /* since power up. */
iva2k 0:e614f7875b60 55 {
iva2k 0:e614f7875b60 56 static int count = 0;
iva2k 0:e614f7875b60 57 return ++count;
iva2k 0:e614f7875b60 58 //return (u32_t) (pTmr->read_us());
iva2k 0:e614f7875b60 59 }
iva2k 0:e614f7875b60 60
iva2k 0:e614f7875b60 61 u32_t sys_now(void)
iva2k 0:e614f7875b60 62 {
iva2k 0:e614f7875b60 63 return (u32_t) (pTmr->read_ms()); //In /ms units
iva2k 0:e614f7875b60 64 }
iva2k 0:e614f7875b60 65 #endif
iva2k 0:e614f7875b60 66
iva2k 0:e614f7875b60 67
iva2k 0:e614f7875b60 68 #ifdef __cplusplus
iva2k 0:e614f7875b60 69 }
iva2k 0:e614f7875b60 70 #endif