This is an example of using the wiconnect API to update the wifi module's internal firmware to the latest version.
It works as follows:
- Instantiate the WiConnect Library
- Initiate Communication with WiFi Module
- Join a network using the specified parameters
- Call the 'updateFirmware' wiconnect API and wait for the update to complete (takes ~60s)
- That's it!
#define NETWORK_SSID "\"<YOUR NETWORK NAME HERE>\""
#define NETWORK_PASSWORD "\"<YOUR NETWORK PASSWORD HERE>\""
#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);
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("Joining network: %s....\r\n", NETWORK_SSID);
{
printf("Failed to send join command\r\n");
for(;;);
}
printf("Updating WiFi module's internal firmware to latest...\r\n");
{
printf("Failed to update the module's firmware\r\n");
for(;;);
}
wiconnect.getVersion();
printf("Version: %s\r\n", wiconnect.getResponseBuffer());
while(true){}
}