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.
lwip/arch/sys_arch.cpp
- Committer:
- iva2k
- Date:
- 2010-06-14
- Revision:
- 1:3ee499525aa5
- Parent:
- 0:e614f7875b60
File content as of revision 1:3ee499525aa5:
#include "sys_arch.h" #include "mbed.h" //DG 2010 #ifdef __cplusplus extern "C" { #endif #ifdef __COMPLEX_AND_BUGGUY_HANDLING__ static Timer* pTmr = NULL; void sys_init(void) { //Start Timer pTmr = new Timer(); pTmr->start(); } u32_t sys_jiffies(void) /* since power up. */ { return (u32_t) (pTmr->read_ms()/10); //In /10ms units } u32_t sys_now(void) { return (u32_t) pTmr->read_ms(); //In /ms units } #elif0 void sys_init(void) { } u32_t sys_jiffies(void) /* since power up. */ { static int count = 0; return ++count; } u32_t sys_now(void) { return (u32_t) time(NULL); } #else static Timer* pTmr = NULL; void sys_init(void) { //Start Timer pTmr = new Timer(); pTmr->start(); } u32_t sys_jiffies(void) /* since power up. */ { static int count = 0; return ++count; //return (u32_t) (pTmr->read_us()); } u32_t sys_now(void) { return (u32_t) (pTmr->read_ms()); //In /ms units } #endif #ifdef __cplusplus } #endif