The Analog value is updated to the server of ponniyin selvan

Dependencies:   EthernetInterface WebSocketClient mbed-rtos mbed

Fork of Websocket_Ethernet_HelloWorld by Mbed

Files at this revision

API Documentation at this revision

Comitter:
divyapriyaks
Date:
Wed Feb 26 09:46:12 2014 +0000
Parent:
3:9bd22e5386cd
Commit message:
IoT-pot value

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Oct 25 00:07:04 2013 +0000
+++ b/main.cpp	Wed Feb 26 09:46:12 2014 +0000
@@ -5,7 +5,9 @@
 Ticker flash;
 DigitalOut led(LED1);
 void flashLED(void){led = !led;}
- 
+
+AnalogIn pot1(p19);
+ char str[200];
  
 int main() 
 {
@@ -20,24 +22,30 @@
     } else {
         error("ethernet failed to connect: %d.\n", ret_val);
     }
+    
+   sprintf(str,"ws://10.1.1.100/test.php?Username=%f",pot1.read());
 
     // view @ http://sockets.mbed.org/demo/viewer
-    Websocket ws("ws://sockets.mbed.org:443/ws/demo/rw");
+    Websocket ws(str);
+    //Websocket ws("ws://sockets.mbed.org:443/ws/demo/rw");
     ws.connect();
-    char str[100];
+    char str[1000];
+    char str2[1000];
     
     for(int i=0; i<0x7fffffff; ++i) {
         // string with a message
-        sprintf(str, "%d WebSocket Hello World over Ethernet", i);
+        //sprintf(str, "POST /test.php HTTP/1.1\r\n Content-Type: application/x-www-form-urlencoded\r\nUser-Agent: Mozilla/5.0\r\n Connection: keep-alive \r\nContent-Length: 47\r\n\n username='rr'&pass='89'");
+        
+        sprintf(str,"POST /test.php HTTP/1.1\r\n HOST: 10.1.1.100\r\n ACCEPT: */*\r\n Referer: http://10.1.1.100/test.php\r\n Content-length: 17\r\n User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 95)\r\n Content-Type: application/x-www-form-urlencoded\r\n Connection: Keep-Alive\r\n \r\n Username=bala\r\r \r\n" );
         ws.send(str);
     
         // clear the buffer and wait a sec...
-        memset(str, 0, 100);
+        memset(str, 0, 1000);
         wait(0.5f);
     
         // websocket server should echo whatever we sent it
-        if (ws.read(str)) {
-            printf("rcv'd: %s\n", str);
+        if (ws.read(str2)) {
+            printf("rcv'd: %s\n", str2);
         }
     }
     ws.close();