Mbed to IFTTT

Dependencies:   EthernetInterface IFTTT mbed-rtos mbed

Fork of TCPSocket_Ethernet by TaChing Yu

Files at this revision

API Documentation at this revision

Comitter:
yu10078999
Date:
Sun Sep 11 01:23:05 2016 +0000
Parent:
0:ea9c19e28331
Child:
2:807d696cf266
Commit message:
0

Changed in this revision

EthernetInterface.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-rtos.lib 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
--- a/EthernetInterface.lib	Thu Sep 08 08:21:49 2016 +0000
+++ b/EthernetInterface.lib	Sun Sep 11 01:23:05 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#183490eb1b4a
+http://mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
--- a/main.cpp	Thu Sep 08 08:21:49 2016 +0000
+++ b/main.cpp	Sun Sep 11 01:23:05 2016 +0000
@@ -1,46 +1,38 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include "TCPSocketConnection.h"
 
-int main() {
-    const char *ip = "0.0.0.0";     //  ip
-    const char *mask ="";          //   遮罩
-    const char *gateway="";         // 閘道器
-    EthernetInterface eth;
-    eth.init(ip,mask,gateway); //Use  static ip
-    //eth.init(); //Use DHCP
+EthernetInterface eth;
+RawSerial pc(USBTX, USBRX); // tx, rx
+
+int main()
+{
+    pc.baud(9600);
+    eth.init(); //Use DHCP
     eth.connect();
-    printf("IP Address is %s\n", eth.getIPAddress());
+    printf("IP Address is %s \n\r", eth.getIPAddress());
+    TCPSocketConnection socket;
     
-    TCPSocketConnection sock;
-    sock.connect("httpbin.org", 80);
+    socket.connect("httpbin.org", 80);
     
     char http_cmd[] = "GET /get?helloworld HTTP/1.0\r\n\r\n";
-    sock.send_all(http_cmd, sizeof(http_cmd)-1);
+    socket.send_all(http_cmd, sizeof(http_cmd)-1);
     
     char buffer[300];
     int ret;
     while (true) {
-        ret = sock.receive(buffer, sizeof(buffer)-1);
+        ret = socket.receive(buffer, sizeof(buffer)-1);
         if (ret <= 0)
             break;
         buffer[ret] = '\0';
         printf("Received %d chars from server:\n%s\n", ret, buffer);
     }
       
-    sock.close();
+    printf("DONE!\n");
+      
+    socket.close();
     
     eth.disconnect();
     
     while(1) {}
 }
-
-// override the default weak function to provide a specific mac address
-extern "C" void mbed_mac_address(char *mac)
-{
-    mac[0] = 0x01;
-    mac[1] = 0x23;
-    mac[2] = 0x45;
-    mac[3] = 0x67;
-    mac[4] = 0x89;
-    mac[5] = 0xAB;
-};
--- a/mbed-rtos.lib	Thu Sep 08 08:21:49 2016 +0000
+++ b/mbed-rtos.lib	Sun Sep 11 01:23:05 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#3da5f554d8bf
+http://mbed.org/users/mbed_official/code/mbed-rtos/#d3d0e710b443
--- a/mbed.bld	Thu Sep 08 08:21:49 2016 +0000
+++ b/mbed.bld	Sun Sep 11 01:23:05 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file