Skip to content

Instantly share code, notes, and snippets.

@futureshocked
Last active January 12, 2020 20:57
Show Gist options
  • Save futureshocked/07b074d44d07171a2e2df7b034bd4fd6 to your computer and use it in GitHub Desktop.
Save futureshocked/07b074d44d07171a2e2df7b034bd4fd6 to your computer and use it in GitHub Desktop.
CheckWifi101FirmwareVersion for my ATWINC1500 breakout
/*
* This example check if the firmware loaded on the WiFi101
* shield is updated.
*
* Circuit:
* - WiFi101 Shield attached
*
* Created 29 July 2015 by Cristian Maglie
* This code is in the public domain.
*/
#include <SPI.h>
#include <WiFi101.h>
#include <driver/source/nmasic.h>
void setup() {
// Initialize serial
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
WiFi.setPins(8,2,4);
// Print a welcome message
Serial.println("WiFi101 firmware check.");
Serial.println();
// Check for the presence of the shield
Serial.print("WiFi101 shield: ");
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("NOT PRESENT");
return; // don't continue
}
Serial.println("DETECTED");
// Print firmware version on the shield
String fv = WiFi.firmwareVersion();
String latestFv;
Serial.print("Firmware version installed: ");
Serial.println(fv);
if (REV(GET_CHIPID()) >= REV_3A0) {
// model B
latestFv = WIFI_FIRMWARE_LATEST_MODEL_B;
} else {
// model A
latestFv = WIFI_FIRMWARE_LATEST_MODEL_A;
}
// 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 shield do not match the");
Serial.println(" version required by the library, you may experience");
Serial.println(" issues or failures.");
}
}
void loop() {
// do nothing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment