wefghuygf
Dependencies: HTTPClient WizFi310Interface_Legacynew mbed
Fork of dweetIo_CloudService_Helloworld_WIZwiki- by
Diff: main.cpp
- Revision:
- 6:1a0f0aa70f49
- Parent:
- 5:95b9bcc5dd34
--- a/main.cpp Tue Oct 24 04:32:01 2017 +0000 +++ b/main.cpp Tue Nov 28 09:06:42 2017 +0000 @@ -1,22 +1,28 @@ #include "mbed.h" -#include "EthernetInterface.h" +//#include "EthernetInterface.h" #include "HTTPClient.h" +#include "WizFi310Interface.h" + +#define SECURE WizFi310::SEC_WPA2_MIXED +#define SSID "CDI" +#define PASS "Cdi*1717" /* SET DHCP */ #define USE_DHCP 1 //--------- Have to modify the mac address------------- unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x34,0x56}; - +#if defined(TARGET_WIZwiki_W7500) + WizFi310Interface wizfi310(D1, D0, D7, D6, D8, NC, 115200); + Serial pc(USBTX, USBRX); +#endif /* IP SET */ //char IP_Addr[] = "192.168.0.100"; //char IP_Subnet[] = "255.255.255.0"; //char IP_Gateway[] = "192.168.0.1"; -Serial pc(USBTX, USBRX); - -EthernetInterface ethernet; +//EthernetInterface ethernet; AnalogIn Sensor(A0); @@ -24,27 +30,16 @@ /// mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres - pc.baud(9600); - #if USE_DHCP - int ret = ethernet.init(MAC_Addr); - #else - 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()); - } 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); - } - + pc.baud(115200); + + printf("WizFi310 STATION. \r\n"); + wizfi310.init(); + printf("After Initialisation. \r\n"); + + printf("After Set Address. \r\n"); + if ( wizfi310.connect(SECURE, SSID, PASS, WizFi310::WM_STATION)) return -1; + printf("After Connect. \r\n"); + printf("IP Address is %s\r\n", wizfi310.getIPAddress()); char str[512]; char msg[128]= ""; @@ -61,7 +56,7 @@ pc.printf("Send post message to dweet.io\r\n"); pc.printf("msg : %s\r\n",msg); - ret = http.get(msg, str, sizeof(str)); + int ret = http.get(msg, str, sizeof(str)); if(!ret) { pc.printf("\r\nPage fetched successfully - read %d characters\r\n", strlen(str));