This is a demo that upload temperature info. to dweet.io

Dependencies:   BLE_API DHT HTTPClient SDFileSystem WIZnet_Library mbed nRF51822

Files at this revision

API Documentation at this revision

Comitter:
Kevin_Lee
Date:
Tue Jun 30 03:40:02 2015 +0000
Child:
1:0f6a216263aa
Commit message:
ethernet;

Changed in this revision

BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
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
nRF51822.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BLE_API.lib	Tue Jun 30 03:40:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#9f4251b3355c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Jun 30 03:40:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/neilt6/code/SDFileSystem/#c2c1f0b16380
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIZnet_Library.lib	Tue Jun 30 03:40:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/WIZnet/code/WIZnet_Library/#cb8808b47e69
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 30 03:40:02 2015 +0000
@@ -0,0 +1,95 @@
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "BLE.h"
+#include "WIZnetInterface.h"
+
+
+#define USE_DHCP 0
+#define LOOPBACKPORT  5000
+int W5500_Test(void);
+SPI spi(SPI_PSELMOSI0, SPI_PSELMISO0, SPI_PSELSCK0);
+WIZnetInterface ethernet(&spi, p24, p17); // Spi ,cs, reset
+int ret, dummy, lv = 1;
+const char * IP_Addr      = "192.168.21.247";
+const char * IP_Subnet    = "255.255.255.0";
+const char * IP_Gateway   = "192.168.21.2";
+unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x1C,0xAA,0xCA};
+ 
+
+DigitalOut myled(LED1);
+//Arch Link
+Serial pc(USBTX, USBRX);  /* uart */
+
+
+int main() {
+    wait(1);
+    pc.baud(115200);
+    wait(1);
+    printf("helloworld\r\n");
+    
+    if(W5500_Test() == 0) {
+        printf("W5500 tested OK \r\n");
+    }
+    
+    while(1) {
+        myled = 1;
+        printf("light1\r\n");
+        wait(3);
+        myled = 0;
+        printf("light0\r\n");
+        wait(3);
+    }
+}
+
+int W5500_Test(void)
+{
+    mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres
+    wait(1);
+    printf("Start to test ethernet!\r\n");
+    
+    #if USE_DHCP
+    printf("use DHCP\r\n");
+    ret = ethernet.init(MAC_Addr);
+    #else
+    printf("do NOT use DHCP\r\n");
+    int ret = ethernet.init(MAC_Addr,IP_Addr,IP_Subnet,IP_Gateway);
+    #endif
+    
+    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());
+            return 0;
+        } else {
+            pc.printf("Error ethernet.connect() - ret = %d\r\n", ret);
+            //exit(0);
+            return -1;
+        }
+    } else {
+        pc.printf("Error ethernet.init() - ret = %d\r\n", ret);
+        //exit(0);
+        return -1;
+    }
+    /*
+    TCPSocketServer server;
+    server.bind(LOOPBACKPORT);
+    server.listen();
+    
+    while (1) {
+        pc.printf("\nWait for new connection...\r\n");
+        TCPSocketConnection client;
+        server.accept(client);
+        client.set_blocking(false, 0); // Timeout=0.
+        pc.printf("Connection from: %s\r\n", client.get_address());
+        while (client.is_connected() == true) {
+            int n = client.receive(buffer, sizeof(buffer));
+            if(n > 0)
+                client.send_all(buffer, n);
+            if(client.is_fin_received())
+                client.close();
+        }
+        pc.printf("Disconnected.\r\n");
+    }*/
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 30 03:40:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF51822.lib	Tue Jun 30 03:40:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#7c68c8d67e1f