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

Revision:
1:3ee499525aa5
Parent:
0:e614f7875b60
--- a/drv/gprs/GPRSModem.cpp	Sat Jun 12 06:01:50 2010 +0000
+++ b/drv/gprs/GPRSModem.cpp	Mon Jun 14 03:24:33 2010 +0000
@@ -61,33 +61,33 @@
   int netState = 0;
   int len;
   len = ATIf::printf("AT+CREG?"); //Registered ?
-  if(!len) DBG("\r\nprintf - len=%d\r\n",len);
+  if(!len) DBG("printf - len=%d\r\n",len);
   if(!len)
     return GPRS_MODEM; //Nothing was actually sent
     
   len = ATIf::scanf("+CREG: 0,%d", &netState); //Get status
-  if(len != 1) DBG("\r\nscanf - len=%d\r\n",len);
+  if(len != 1) DBG("scanf - len=%d\r\n",len);
   if(len != 1) //Likely +CMS ERROR was returned
     return GPRS_MODEM;
 
   if( !!ATIf::checkOK() ) //Should not be a problem
-    {DBG("\r\nNOK\r\n"); return GPRS_MODEM; }
+    {DBG("NOK\r\n"); return GPRS_MODEM; }
     
   switch(netState)
   {
   case 1:
   case 5: //TODO: Option allow roaming
-    DBG("\r\nNetwork is up!\r\n");
+    DBG("Network is up!\r\n");
     return GPRS_OK;
   case 3:
-    DBG("\r\nAccess to network denied.\r\n");
+    DBG("Access to network denied.\r\n");
     return GPRS_DENIED;
   case 0:
-    DBG("\r\nNo network.\r\n");
+    DBG("No network.\r\n");
     return GPRS_NONETWORK;
   case 4:
   case 2:
-    //DBG("\r\nRegistering...\r\n");
+    //DBG("Registering...\r\n");
     return GPRS_REGISTERING;
   }
     
@@ -134,7 +134,7 @@
     return GPRS_MODEM; //Nothing was actually sent
     
   len = ATIf::scanf("+CGREG: %*d,%d", &netState); //Get GPRS status, see GSM 07.07 spec as Telit AT ref is wrong
-  if(len != 1) DBG("\r\nscanf - len=%d\r\n",len);
+  if(len != 1) DBG("scanf - len=%d\r\n",len);
   if(len != 1) //Likely +CMS ERROR was returned
     return GPRS_MODEM;
 
@@ -145,17 +145,17 @@
   {
   case 1:
   case 5: //TODO: Option allow roaming
-    DBG("\r\nNetwork is up!\r\n");
+    DBG("Network is up!\r\n");
     return GPRS_OK;
   case 3:
-    DBG("\r\nAccess to network denied.\r\n");
+    DBG("Access to network denied.\r\n");
     return GPRS_DENIED;
   case 0:
-    DBG("\r\nNo network.\r\n");
+    DBG("No network.\r\n");
     return GPRS_NONETWORK;
   case 4:
   case 2:
-    DBG("\r\nRegistering...\r\n");
+    DBG("Registering...\r\n");
     return GPRS_REGISTERING;
   }
     
@@ -172,7 +172,7 @@
   if(err)
     return err;
   
-  DBG("\r\nAttaching GPRS...\r\n");
+  DBG("Attaching GPRS...\r\n");
   ATIf::setReadMode(false); //Discard chars
   ATIf::setTimeout(10000);
   ATIf::setLineMode(true); //Line mode
@@ -202,7 +202,7 @@
 GPRSErr GPRSModem::setGPRSDown()
 { 
   ATIf::flushBuffer();
-  DBG("\r\nDetaching GPRS...\r\n");
+  DBG("Detaching GPRS...\r\n");
   ATIf::setReadMode(false); //Discard chars
   ATIf::setTimeout(10000);
   ATIf::setLineMode(true); //Line mode
@@ -228,7 +228,7 @@
   ATIf::setTimeout(5000);
   ATIf::setLineMode(true); //Line mode
   
-  DBG("\r\nConnecting...\r\n");  
+  DBG("Connecting...\r\n");  
   
   int len;
   
@@ -262,7 +262,7 @@
     
   ATIf::setSignals(false);
   
-  DBG("\r\nConnected.\r\n");
+  DBG("Connected.\r\n");
     
   return GPRS_OK; //Time to enter a PPP Session !   
   
@@ -283,7 +283,7 @@
   if(err)
     return err;
     
-  DBG("\r\nDisconnected.\r\n");
+  DBG("Disconnected.\r\n");
     
   return GPRS_OK;
 }