Skip to content

Commit 12259e3

Browse files
committed
Added example CheckFirmwareVersion.ino
Added check firmware version example, CheckFirmwareVersion.ino.
1 parent 02eee85 commit 12259e3

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ script:
3939
- buildExampleSketch WiFiWebClientRepeating
4040
- buildExampleSketch WiFiWebServer
4141
- if [[ "$BOARD" =~ "arduino:samd:" ]]; then
42+
buildExampleToolsSketch CheckFirmwareVersion
4243
buildExampleToolsSketch FirmwareUpdater;
4344
buildExampleToolsSketch SerialNINAPassthrough;
4445
fi
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* This example check if the firmware loaded on the NINA module
3+
* is updated.
4+
*
5+
* Circuit:
6+
* - Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and UNO WiFi Rev.2)
7+
*
8+
* Created 17 October 2018 by Riccardo Rosario Rizzo
9+
* This code is in the public domain.
10+
*/
11+
#include <SPI.h>
12+
#include <WiFiNINA.h>
13+
14+
void setup() {
15+
// Initialize serial
16+
Serial.begin(9600);
17+
while (!Serial) {
18+
; // wait for serial port to connect. Needed for native USB port only
19+
}
20+
21+
// Print a welcome message
22+
Serial.println("WiFiNINA firmware check.");
23+
Serial.println();
24+
25+
// check for the WiFi module:
26+
if (WiFi.status() == WL_NO_MODULE) {
27+
Serial.println("Communication with WiFi module failed!");
28+
// don't continue
29+
while (true);
30+
}
31+
32+
// Print firmware version on the module
33+
String fv = WiFi.firmwareVersion();
34+
String latestFv;
35+
Serial.print("Firmware version installed: ");
36+
Serial.println(fv);
37+
38+
latestFv = WIFI_FIRMWARE_LATEST_VERSION;
39+
40+
// Print required firmware version
41+
Serial.print("Latest firmware version available : ");
42+
Serial.println(latestFv);
43+
44+
// Check if the latest version is installed
45+
Serial.println();
46+
if (fv == latestFv) {
47+
Serial.println("Check result: PASSED");
48+
} else {
49+
Serial.println("Check result: NOT PASSED");
50+
Serial.println(" - The firmware version on the module do not match the");
51+
Serial.println(" version required by the library, you may experience");
52+
Serial.println(" issues or failures.");
53+
}
54+
}
55+
56+
void loop() {
57+
// do nothing
58+
}
59+

src/WiFi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#ifndef WiFi_h
2222
#define WiFi_h
2323

24+
#define WIFI_FIRMWARE_LATEST_VERSION "1.1.0"
25+
2426
#include <inttypes.h>
2527

2628
extern "C" {

0 commit comments

Comments
 (0)