testing
Dependencies: HTTPClient PowerControl SNICInterface_mod mbed-rtos mbed
Fork of Fx0Hackson by
Diff: main.cpp
- Revision:
- 3:837766adc429
- Parent:
- 2:270e2d0bb85a
- Child:
- 5:3dbedd084f79
diff -r 270e2d0bb85a -r 837766adc429 main.cpp --- a/main.cpp Thu Aug 30 15:42:06 2012 +0000 +++ b/main.cpp Fri Jan 23 09:56:32 2015 +0000 @@ -1,20 +1,49 @@ #include "mbed.h" -#include "EthernetInterface.h" +#include "SNIC_WifiInterface.h" #include "HTTPClient.h" -EthernetInterface eth; +#if defined(TARGET_LPC1768) +#include "PowerControl/EthernetPowerControl.h" +#endif + +#define DEMO_AP_SSID "SSID" +#define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_AES +#define DEMO_AP_SECUTIRY_KEY "PASSWORD" + +C_SNIC_WifiInterface wifi( p9, p10, NC, NC, p30 ); + HTTPClient http; char str[512]; int main() { - eth.init(); //Use DHCP +#if defined(TARGET_LPC1768) + PHY_PowerDown(); +#endif + + wifi.init(); //Use DHCP - eth.connect(); + wait(0.5); + int s = wifi.disconnect(); + if( s != 0 ) { + return -1; + } + + wait(0.3); + // Connect AP + wifi.connect( DEMO_AP_SSID + , strlen(DEMO_AP_SSID) + , DEMO_AP_SECURITY_TYPE + , DEMO_AP_SECUTIRY_KEY + , strlen(DEMO_AP_SECUTIRY_KEY) ); + wait(0.5); + wifi.setIPConfig( true ); + wait(0.5); + printf("IP Address is %s\n", wifi.getIPAddress()); //GET data printf("\nTrying to fetch page...\n"); - int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128); + int ret = http.get("http://developer.mbed.org/media/uploads/donatien/hello.txt", str, 128); if (!ret) { printf("Page fetched successfully - read %d characters\n", strlen(str)); @@ -72,7 +101,7 @@ printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); } - eth.disconnect(); + wifi.disconnect(); while(1) { }