Simple Thing For VIT

Dependencies:   WIZnet_Library mbed

Files at this revision

API Documentation at this revision

Comitter:
ganeshgore
Date:
Tue Jun 30 11:18:54 2015 +0000
Commit message:
Initial;

Changed in this revision

WIZnet_Library.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
diff -r 000000000000 -r 9abf70ba4b3f WIZnet_Library.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIZnet_Library.lib	Tue Jun 30 11:18:54 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ganeshgore/code/WIZnet_Library/#d4a7d43fb16f
diff -r 000000000000 -r 9abf70ba4b3f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 30 11:18:54 2015 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+#include "WIZnetInterface.h"
+
+unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x07,0x07};
+
+char* Update_Key = "YTDILMQL53ASDCJ4";
+char* ServerIP = "184.106.153.149";
+int Count = 15;
+
+Serial pc(USBTX, USBRX);
+SPI spi(PTD2,PTD3,PTD1);
+WIZnetInterface ethernet(&spi,PTD0,PTA20);
+AnalogIn temp(PTC1);
+
+
+int main()
+{
+    //Set serial port baudrate speed: 19200
+    pc.baud(19200);
+    pc.printf("Start\r\n");
+    
+    while(1) {
+        int ret = ethernet.init(MAC_Addr);
+        
+        if (!ret) {
+            pc.printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress());
+            ret = ethernet.connect();
+            if (!ret) {
+                pc.printf("IP: %s, MASK: %s, GW: %s\r\n",
+                          ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway());
+            } else {
+                pc.printf("Error ethernet.connect() - ret = %d\r\n", ret);
+                exit(0);
+            }
+        } else {
+            pc.printf("Error ethernet.init() - ret = %d\r\n", ret);
+            exit(0);
+        }  
+    
+    TCPSocketConnection sock;
+    sock.connect("184.106.153.149", 80);
+    if(sock.is_connected())
+        pc.printf("Socket Connected\n\r");
+    else
+        pc.printf("Socket NoT Connected\n\r");
+    
+    
+    char buffer[300];
+    int ret_t;
+    
+    char http_cmd[256]; 
+    sprintf(http_cmd,"GET /update?key=YTDILMQL53ASDCJ4&field1=500 HTTP/1.0\n\n");
+    printf("Running - %s\r\n",http_cmd);
+    sock.send_all(http_cmd, sizeof(http_cmd)-1);
+        
+    ret_t = sock.receive(buffer, sizeof(buffer)-1);
+    buffer[ret_t] = '\0';
+    printf("Received %d chars from server:\n%s\r\n", ret_t, buffer);
+        
+    sock.close();
+    
+    ethernet.disconnect();
+    printf("Socket Closed");
+    
+    while(1);
+}
+}
diff -r 000000000000 -r 9abf70ba4b3f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 30 11:18:54 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file