Dependencies:   EthernetNetIf TextLCD mbed DNSResolver

Files at this revision

API Documentation at this revision

Comitter:
takahashim
Date:
Mon Feb 27 06:55:17 2012 +0000
Commit message:

Changed in this revision

DNSResolver.lib Show annotated file Show diff for this revision Revisions of this file
EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
Websocket.lib Show annotated file Show diff for this revision Revisions of this file
Wifly.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DNSResolver.lib	Mon Feb 27 06:55:17 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hlipka/code/DNSResolver/#097d4993dd1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetNetIf.lib	Mon Feb 27 06:55:17 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Mon Feb 27 06:55:17 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Websocket.lib	Mon Feb 27 06:55:17 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/Websocket/#2c4462ca74fa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Wifly.lib	Mon Feb 27 06:55:17 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/Wifly/#f524a28790b1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 27 06:55:17 2012 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "Websocket.h"
+#include "TextLCD.h"
+
+#define WS_SERVER_URL "ws://sockets.mbed.org/ws/webdbpress/rw"
+
+Websocket *ws;
+TextLCD lcd(p24, p26, p27, p28, p29, p30);
+AnalogIn ain(p15);
+float temp;
+
+int main() {
+    int i = 0;
+    char buf[512];
+    Timer timer;
+
+    lcd.printf("init network...\n");
+    ws = new Websocket(WS_SERVER_URL);
+
+    lcd.printf("connecting...\n");
+    while(!ws->connect()) {
+        printf("retrying...\r\n");
+        wait(5);
+    }
+
+    timer.start();
+    while(1) {
+        Net::poll();
+        wait(0.1);
+
+        if (timer.read_ms() >= 10000) {
+            temp = ain * 3.3 * 100;
+            sprintf(buf, "No.%d: temp:%4.2f", i++, temp);
+            ws->send(buf);
+            timer.reset();
+        }
+        
+        if (ws->read(buf)) {
+            lcd.cls();
+            lcd.printf("recv: %s\n", buf);
+        }
+
+        if (! ws->connected()) {
+            lcd.cls();
+            lcd.printf("disconnected\n");
+            break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 27 06:55:17 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5364839841bd