This is an example of using the web setup network API to configure the module network credentials remotely.
#define WEB_SETUP_SSID "\"WiConnect WebSetup Example\""
#define WEB_SETUP_PASSWORD "password"
#include <stdio.h>
#include "target_config.h"
#include "Wiconnect.h"
static void webSetupCompleteCallback(
WiconnectResult result,
void *arg1,
void *arg2);
static Serial consoleSerial(STDIO_UART_TX, STDIO_UART_RX);
static uint8_t wiconnectInternalBuffer[256];
static volatile bool webSetupCompleteFlag = false;
int main(int argc, char **argv)
{
consoleSerial.baud(115200);
SerialConfig serialConfig(WICONNECT_RX_PIN, WICONNECT_TX_PIN, 256, NULL);
Wiconnect wiconnect(serialConfig, sizeof(wiconnectInternalBuffer), wiconnectInternalBuffer, WICONNECT_RESET_PIN);
printf("Initializing WiConnect Library...\r\n");
{
printf("Failed to initialize communication with WiFi module!\r\n"
"Make sure the wires are connected correctly\r\n");
for(;;);
}
printf("Starting Websetup...\r\n");
if(wiconnect.startWebSetup(WEB_SETUP_SSID, WEB_SETUP_PASSWORD, Callback(webSetupCompleteCallback)) !=
WICONNECT_SUCCESS)
{
printf("Failed to start web setup\r\n");
for(;;);
}
printf("Web setup has started.\r\n\r\n");
printf("1. Using your phone (or PC, Mac, Linux, etc.)\r\n connect to the WiFi network: %s\r\n", WEB_SETUP_SSID);
printf("2. The password is: %s\r\n", WEB_SETUP_PASSWORD);
printf("3. Once connected, open your browser and enter the URL: http://setup.com\r\n");
printf("4. This will bringup a setup page, enter your router's credentials.\r\n");
printf("5. Click the 'Save & Exit' button at the bottom of the webpage\r\n\r\n");
while(!webSetupCompleteFlag)
{
}
printf("IP Address: %s\r\n", wiconnect.getIpAddress());
printf("Web setup example has completed!\r\n");
while(true){}
}
static void webSetupCompleteCallback(
WiconnectResult result,
void *arg1,
void *arg2)
{
webSetupCompleteFlag = true;
}