Team 6

Dependencies:   HTTPClient PowerControl SNICInterface_mod mbed-rtos mbed

Fork of HTTPClient_WiFi_HelloWorld by KDDI Fx0 hackathon

Committer:
daisukekmr
Date:
Sat Feb 14 09:06:17 2015 +0000
Revision:
6:1273e99a6058
Parent:
5:3dbedd084f79
Child:
7:bf74da76618b
Origin

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:0e0debc29569 1 #include "mbed.h"
MACRUM 5:3dbedd084f79 2
MACRUM 3:837766adc429 3 #include "SNIC_WifiInterface.h"
donatien 0:0e0debc29569 4 #include "HTTPClient.h"
MACRUM 3:837766adc429 5 #if defined(TARGET_LPC1768)
MACRUM 3:837766adc429 6 #include "PowerControl/EthernetPowerControl.h"
MACRUM 3:837766adc429 7 #endif
MACRUM 3:837766adc429 8
daisukekmr 6:1273e99a6058 9 #define DEMO_AP_SSID "nad11-10e168"
MACRUM 3:837766adc429 10 #define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_AES
daisukekmr 6:1273e99a6058 11 #define DEMO_AP_SECUTIRY_KEY "18e36c5e791f9"
MACRUM 3:837766adc429 12
MACRUM 3:837766adc429 13 C_SNIC_WifiInterface wifi( p9, p10, NC, NC, p30 );
MACRUM 3:837766adc429 14
MACRUM 5:3dbedd084f79 15 #if defined(_DEBUG)
MACRUM 5:3dbedd084f79 16 Serial pc(USBTX, USBRX);
MACRUM 5:3dbedd084f79 17 #endif
MACRUM 5:3dbedd084f79 18
donatien 1:d263603373ac 19 HTTPClient http;
donatien 1:d263603373ac 20 char str[512];
donatien 1:d263603373ac 21
donatien 0:0e0debc29569 22 int main()
donatien 0:0e0debc29569 23 {
MACRUM 3:837766adc429 24 #if defined(TARGET_LPC1768)
MACRUM 3:837766adc429 25 PHY_PowerDown();
MACRUM 3:837766adc429 26 #endif
MACRUM 3:837766adc429 27
MACRUM 3:837766adc429 28 wifi.init(); //Use DHCP
donatien 0:0e0debc29569 29
MACRUM 3:837766adc429 30 wait(0.5);
MACRUM 3:837766adc429 31 int s = wifi.disconnect();
MACRUM 3:837766adc429 32 if( s != 0 ) {
MACRUM 3:837766adc429 33 return -1;
MACRUM 3:837766adc429 34 }
MACRUM 3:837766adc429 35
MACRUM 3:837766adc429 36 wait(0.3);
MACRUM 3:837766adc429 37 // Connect AP
MACRUM 3:837766adc429 38 wifi.connect( DEMO_AP_SSID
MACRUM 3:837766adc429 39 , strlen(DEMO_AP_SSID)
MACRUM 3:837766adc429 40 , DEMO_AP_SECURITY_TYPE
MACRUM 3:837766adc429 41 , DEMO_AP_SECUTIRY_KEY
MACRUM 3:837766adc429 42 , strlen(DEMO_AP_SECUTIRY_KEY) );
MACRUM 3:837766adc429 43 wait(0.5);
MACRUM 3:837766adc429 44 wifi.setIPConfig( true );
MACRUM 3:837766adc429 45 wait(0.5);
MACRUM 3:837766adc429 46 printf("IP Address is %s\n", wifi.getIPAddress());
donatien 0:0e0debc29569 47
donatien 0:0e0debc29569 48 //GET data
donatien 2:270e2d0bb85a 49 printf("\nTrying to fetch page...\n");
MACRUM 3:837766adc429 50 int ret = http.get("http://developer.mbed.org/media/uploads/donatien/hello.txt", str, 128);
donatien 0:0e0debc29569 51 if (!ret)
donatien 0:0e0debc29569 52 {
donatien 0:0e0debc29569 53 printf("Page fetched successfully - read %d characters\n", strlen(str));
donatien 0:0e0debc29569 54 printf("Result: %s\n", str);
donatien 0:0e0debc29569 55 }
donatien 0:0e0debc29569 56 else
donatien 0:0e0debc29569 57 {
donatien 0:0e0debc29569 58 printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
donatien 0:0e0debc29569 59 }
donatien 1:d263603373ac 60
MACRUM 3:837766adc429 61 wifi.disconnect();
donatien 0:0e0debc29569 62
donatien 0:0e0debc29569 63 while(1) {
donatien 0:0e0debc29569 64 }
donatien 0:0e0debc29569 65 }