st-anything/lib/WiFiNINA/examples/Tools/CheckFirmwareVersion/CheckFirmwareVersion.ino
Gašper Dobrovoljc ec125f27db
IP Configuration
2023-03-11 15:11:03 +01:00

59 lines
1.5 KiB
C++

/*
* This example checks if the firmware loaded on the NINA module
* is updated.
*
* Circuit:
* - Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and UNO WiFi Rev.2)
*
* Created 17 October 2018 by Riccardo Rosario Rizzo
* This code is in the public domain.
*/
#include <SPI.h>
#include <WiFiNINA.h>
void setup() {
// Initialize serial
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// Print a welcome message
Serial.println("WiFiNINA firmware check.");
Serial.println();
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
// Print firmware version on the module
String fv = WiFi.firmwareVersion();
String latestFv;
Serial.print("Firmware version installed: ");
Serial.println(fv);
latestFv = WIFI_FIRMWARE_LATEST_VERSION;
// Print required firmware version
Serial.print("Latest firmware version available : ");
Serial.println(latestFv);
// Check if the latest version is installed
Serial.println();
if (fv >= latestFv) {
Serial.println("Check result: PASSED");
} else {
Serial.println("Check result: NOT PASSED");
Serial.println(" - The firmware version on the module does not match the");
Serial.println(" version required by the library, you may experience");
Serial.println(" issues or failures.");
}
}
void loop() {
// do nothing
}