modify
Dependencies: Adafruit_GFX Adafruit_ST7735 GMMP_mbed NTPClient SDFileSystem WIZnet_Library mbed
Fork of ThingPlug_Ethernet_Example_temp_V2 by
Revision 6:f3e13103ea9d, committed 2015-08-12
- Comitter:
- lesmin
- Date:
- Wed Aug 12 09:14:06 2015 +0000
- Parent:
- 5:9872115ead79
- Child:
- 7:6534e4a59e63
- Commit message:
- applied the latest version of GMMP_mbed library
Changed in this revision
GMMP_mbed.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 |
--- a/GMMP_mbed.lib Wed Aug 12 06:53:20 2015 +0000 +++ b/GMMP_mbed.lib Wed Aug 12 09:14:06 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/SKTelecom_ThingPlug/code/GMMP_mbed/#a1e5bf5ba925 +https://developer.mbed.org/teams/SKTelecom_ThingPlug/code/GMMP_mbed/#e210cb961300
--- a/main.cpp Wed Aug 12 06:53:20 2015 +0000 +++ b/main.cpp Wed Aug 12 09:14:06 2015 +0000 @@ -5,6 +5,16 @@ #include "config.h" + #ifdef USE_SNIC_WIFI + #include "SNIC_WifiInterface.h" + C_SNIC_WifiInterface wifi( D8, D2, NC, NC, D3); + #endif//USE_SNIC_WIFI + + #ifdef USE_WIZNET_W5500 + #include "WIZnetInterface.h" + WIZnetInterface ethernet(PA_7, PA_6, PA_5, PB_6, PA_9);//scs(PB_6), nRESET(PA_9); // reset pin is dummy, don't affect any pin of WIZ550io + #endif//USE_WIZNET_W5500 + /** * GMMP Test Code */ @@ -305,6 +315,65 @@ infoln("Start setup()"); + #ifdef USE_SNIC_WIFI + wifi.init(); + + wait(0.5); + int s = wifi.disconnect(); + if( s != 0 ) { + return -1; + } + + wait(0.3); + // Connect AP + wifi.connect( MBED_AP_SSID + , strlen(MBED_AP_SSID) + , MBED_AP_SECURITY_TYPE + , MBED_AP_SECUTIRY_KEY + , strlen(MBED_AP_SECUTIRY_KEY) ); + wait(0.5); + wifi.setIPConfig( true ); //Use DHCP + wait(0.5); + + tagWIFI_STATUS_T wifi_status; + if( wifi.getWifiStatus(&wifi_status) ) printf("wifi_status error!\r\n"); + + printf("MAC Address is %02x:%02x:%02x:%02x:%02x:%02x\r\n", + wifi_status.mac_address[0], wifi_status.mac_address[1], wifi_status.mac_address[2], + wifi_status.mac_address[3], wifi_status.mac_address[4], wifi_status.mac_address[5]); + printf("IP Address is %s\r\n", wifi.getIPAddress()); + #endif//USE_SNIC_WIFI + + #ifdef USE_WIZNET_W5500 + //mbed_mac_address((char *)MAC_Addr); //Use mbed mac addres + printf("input MAC Address is %02x:%02x:%02x:%02x:%02x:%02x\r\n", + g_mac[0], g_mac[1], g_mac[2], g_mac[3], g_mac[4], g_mac[5]); + + int ret2 = ethernet.init(g_mac); + //printf("SPI Initialized \r\n"); + //wait(1); // 1 second for stable state + + printf("W5500 Networking Started \r\n"); + //wait(1); // 1 second for stable state + + if (!ret2) { + printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress()); + ret2 = ethernet.connect(); + if (!ret2) { + printf("IP: %s, MASK: %s, GW: %s\r\n", + ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway()); + } else { + printf("Error ethernet.connect() - ret = %d\r\n", ret2); + //exit(0); + } + } else { + printf("Error ethernet.init() - ret = %d\r\n", ret2); + //exit(0); + } + + #endif//USE_WIZNET_W5500 + + startSensingTemp(); //lesmin if ( Initialize(serverIp, nServerPort, pszDomainCode, pszGWAuthID, g_mac) ) {