3 #include "target_config.h"
5 #define NETWORK_SSID "<YOUR NETWORK SSID HERE>"
6 #define NETWORK_PASSWORD "<YOUR NETWORK PASSWORD HERE>"
8 #define ECHO_SERVER_ADDRESS "<YOUR LOCAL IP ADDRESS HERE>"
9 #define ECHO_SERVER_PORT 7
12 static Serial consoleSerial(STDIO_UART_TX, STDIO_UART_RX);
19 SerialConfig serialConfig(WICONNECT_RX_PIN, WICONNECT_TX_PIN, 256);
20 Wiconnect wiconnect(serialConfig, 256, NULL, WICONNECT_RESET_PIN);
22 consoleSerial.baud(115200);
26 printf(
"Failed to initialize Wiconnect: %s\r\n", Wiconnect::getWiconnectResultStr(result));
29 printf(
"The WiFi firmware is not supported. Run the ota example to update the firmware:\r\n");
30 printf(
"https://developer.mbed.org/teams/ACKme/code/wiconnect-ota_example");
34 else if(
WICONNECT_FAILED(result, wiconnect.join(NETWORK_SSID, NETWORK_PASSWORD)))
36 printf(
"Failed to join network: %s\r\n", Wiconnect::getWiconnectResultStr(result));
40 printf(
"IP Address is %s\n", wiconnect.getIpAddress());
42 TCPSocketConnection socket;
43 while (socket.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT) < 0)
45 printf(
"Unable to connect to (%s) on port (%d)\r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
49 char hello[] =
"Hello World\n";
50 if(socket.send_all(hello,
sizeof(hello) - 1) == -1)
52 printf(
"Failed to send data\r\n");
56 int n = socket.receive(buf, 256);
59 printf(
"Failed to receive data\r\n");
WiconnectResult
API Result code.
Host<->Wiconnect Module serial configuration.
The WiFi module's firmware is out-dated. See updateFirmware() to update the firmware.
The root WiConnect library class. This class inheriets all WiConnect functionality.
#define WICONNECT_FAILED(result, func)
Populates result with return value from func, returns TRUE if return value contains error...