This is an example of using the http socket API to download a webpage.
#define HTTP_URL "http://ack.me"
#include <stdio.h>
#include "target_config.h"
#include "Wiconnect.h"
static Serial consoleSerial(STDIO_UART_TX, STDIO_UART_RX);
int main(int argc, char **argv)
{
consoleSerial.baud(115200);
SerialConfig serialConfig(WICONNECT_RX_PIN, WICONNECT_TX_PIN, 256, NULL);
Wiconnect wiconnect(serialConfig, 256, NULL, WICONNECT_RESET_PIN);
wiconnect.setCommandDefaultTimeout(15000);
printf("Initializing WiConnect Library...\r\n");
{
{
printf("The WiFi firmware is not supported. Run the ota example to update the firmware:\r\n");
printf("https://developer.mbed.org/teams/ACKme/code/wiconnect-ota_example");
}
else
{
printf("Failed to initialize communication with WiFi module!\r\n"
"Make sure the wires are connected correctly\r\n");
}
for(;;);
}
WiconnectSocket socket(256);
printf("Issuing HTTP Request: %s\r\n", HTTP_URL);
{
printf("Failed to issue HTTP request. Does the module have valid network credentials?\r\n");
for(;;);
}
uint8_t *dataPtr;
uint16_t dataLength;
{
fwrite(dataPtr, 1, dataLength, stdout);
}
printf("HTTP GET example has completed!\r\n");
while(true){}
}