Websocket Test Program for W5500 (WIZ550io) FRDM-KL25Z WIZ550io Ethernet Board.

Dependencies:   W5500Interface WebSocketClient mbed

Fork of Websocket_Ethernet_W5500 by W5500-Ethernet-Interface Makers

Websocket example using Ethernet component of WIZ550io (W5500). FRDM-KL25Z is used.

Files at this revision

API Documentation at this revision

Comitter:
embeddist
Date:
Wed Jul 09 08:12:50 2014 +0000
Parent:
3:4c02f6287752
Child:
5:5f427a506928
Commit message:
-Websocket for KL25Z, W5500 or WIZ550io

Changed in this revision

DS18B20Sensor.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DS18B20Sensor.lib	Tue Jul 08 23:58:21 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/Bongjun/code/DS18B20Sensor/#0bcc4e42fec0
--- a/main.cpp	Tue Jul 08 23:58:21 2014 +0000
+++ b/main.cpp	Wed Jul 09 08:12:50 2014 +0000
@@ -1,10 +1,11 @@
 #include "mbed.h"
 #include "EthernetInterfaceW5500.h"
 #include "Websocket.h"
-#include "DS18B20Sensor.h"
+
 
+#define _DHCP
 DigitalOut myled(LED1);
-DS18B20Sensor sensor(P1_25);
+//DS18B20Sensor sensor(P1_25);
 
 int main()
 {
@@ -24,11 +25,16 @@
     spi.format(8,0); // 8bit, mode 0
     spi.frequency(7000000); // 7MHz
     wait(1); // 1 second for stable state
+#elif defined(TARGET_KL25Z)
+    SPI spi(D11, D12, D13); // mosi, miso, sclk
+    EthernetInterfaceW5500 eth(&spi, D10, PTA20);//, nRESET(p9); // reset pin is dummy, don't affect any pin of WIZ550io
+
 
 #endif
-
+   uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x1c, 0xb8, 0x4a};
+   
 #ifdef _DHCP
-    eth.init(); //Use DHCP
+    eth.init((uint8_t *)mac_addr); //Use DHCP
     eth.connect();
     //printf("IP Address is %s\n\r", eth.getIPAddress());
     printf("Initialized, MAC: %s\n", eth.getMACAddress());
@@ -37,7 +43,8 @@
 
 #else
     // as your env. change to real IP address and so on.
-    int ret = eth.init("222.98.173.212", "255.255.255.192", "222.98.173.254");
+    //int ret = eth.init("222.98.173.212", "255.255.255.192", "222.98.173.254");
+    int ret = eth.init((uint8_t *)mac_addr, "192.168.77.10", "255.255.255.0", "192.168.77.1");
     if (!ret) {
         printf("Initialized, MAC: %s\n", eth.getMACAddress());
         printf("Connected, IP: %s, MASK: %s, GW: %s\n",
@@ -58,6 +65,7 @@
     ws.connect();
 
     char str[100];
+/*
     char sensorBuf[25];
 
     uint8_t result;
@@ -65,21 +73,10 @@
 
     //Before using this sensor, should called sensor.count() once.
     sensor_cnt = sensor.count();
+*/
 
     for(int i=0; i<0x10; ++i) {
-        // string with a message
-        if (sensor_cnt) {
-            result = sensor.startReading(true);     // start sensor readings and wait
-            if (result == DS18X20_OK) {
-                sensor.getReading(sensorBuf, 0);         // get result into buf
-                sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet : Current Temperature is %s", i, sensorBuf);
-            } else {
-                sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet", i);
-            }
-        } else {
-            sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet : No Sensor", i);
-        }
-
+        sprintf(str, "%d WebSocket for WIZnet W5500 Hello World over Ethernet : No Sensor", i);
         ws.send(str);
 
         // clear the buffer and wait a sec...