EthW5500+STM32

Dependencies:   MQTT WIZnet_Library mbed

Fork of EthW5500 by YX ZHANG

Revision:
4:10f83daba9ea
Parent:
3:54ad271708ff
Child:
5:23424c038538
--- a/main.cpp	Fri Apr 20 01:37:27 2018 +0000
+++ b/main.cpp	Fri Apr 20 07:28:56 2018 +0000
@@ -3,29 +3,27 @@
 #include "MQTTSocket.h"
 #include "MQTTClient.h"
 #include "ETHW5500.h"
-
-DigitalIn BTN(PC_13);
+Serial pc(PA_2,PA_3);//串口
+//W5500接线 mosi,miso,sclk,cs,reset
+WIZnetInterface wiz(PA_7,PA_6,PA_5,PB_5,PB_4);
+DigitalIn BTN(PA_4);//按键
 //节点名称任取
 char *NODE_NAME="n_12345";
  //接在同一子网下的设备MAC地址必须不同
 uint8_t mac_addr[6]={0x50,0x51,0x50,0x00,0x00,0x01};
-//服务器地址
-char *SeverURL="tdxls-iot.xicp.net";
 
 int main() {
-    
-    const char* actuators = "switch,int\n";
+        const char* actuators = "switch,int\n";
     const char* sensors = "analog,mV\n";
-    
-    Eth_Init(mac_addr);//初始化
-    Eth_ConnectToSer(SeverURL);//连接到服务器
+        pc.printf("Initing\n");
+        Eth_Init(mac_addr);
     
-    Eth_Subscribe("control",NODE_NAME,"switch");//订阅服务器信息
+    Eth_Subscribe("control",NODE_NAME,"switch");
     
-    Eth_Report("event",NODE_NAME,"online",NULL,0,false);//报告节点状态
-    Eth_Report("capability",NODE_NAME,"control",actuators,strlen(actuators),true);//报告传感器参数
-    Eth_Report("capability",NODE_NAME,"values",sensors,strlen(sensors),true);
-    bool btn = 0;//报告GPIO电平
+    Eth_Report("event",NODE_NAME,"online",NULL,0,false);
+        Eth_Report("capability",NODE_NAME,"control",actuators,strlen(actuators),true);
+        Eth_Report("capability",NODE_NAME,"values",sensors,strlen(sensors),true);
+    bool btn = 0;
     while(1){
         bool newBTN = BTN;
         if(newBTN != btn){