1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-05 13:16:13 +03:00

WiFi Shield examples: added the firmware version check

This commit is contained in:
Fede85
2014-02-06 18:40:48 +01:00
parent b415903b69
commit 5dfafe7847
13 changed files with 406 additions and 362 deletions

View File

@@ -12,6 +12,7 @@
modified 31 May 2012 modified 31 May 2012
by Tom Igoe by Tom Igoe
*/ */
#include <SPI.h>
#include <WiFi.h> #include <WiFi.h>
char ssid[] = "yourNetwork"; // the name of your network char ssid[] = "yourNetwork"; // the name of your network
@@ -31,6 +32,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to open SSID: "); Serial.print("Attempting to connect to open SSID: ");

View File

@@ -22,6 +22,7 @@
modified 31 May 2012 modified 31 May 2012
by Tom Igoe by Tom Igoe
*/ */
#include <SPI.h>
#include <WiFi.h> #include <WiFi.h>
char ssid[] = "yourNetwork"; // your network SSID (name) char ssid[] = "yourNetwork"; // your network SSID (name)
@@ -43,6 +44,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WEP network, SSID: "); Serial.print("Attempting to connect to WEP network, SSID: ");

View File

@@ -12,6 +12,7 @@
modified 31 May 2012 modified 31 May 2012
by Tom Igoe by Tom Igoe
*/ */
#include <SPI.h>
#include <WiFi.h> #include <WiFi.h>
char ssid[] = "yourNetwork"; // your network SSID (name) char ssid[] = "yourNetwork"; // your network SSID (name)
@@ -32,6 +33,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: "); Serial.print("Attempting to connect to WPA SSID: ");

View File

@@ -32,6 +32,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// Print WiFi MAC address: // Print WiFi MAC address:
printMacAddress(); printMacAddress();

View File

@@ -40,6 +40,10 @@ void setup() {
while (true); // don't continue while (true); // don't continue
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: "); Serial.print("Attempting to connect to Network named: ");

View File

@@ -47,6 +47,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: "); Serial.print("Attempting to connect to SSID: ");
@@ -57,6 +61,7 @@ void setup() {
// wait 10 seconds for connection: // wait 10 seconds for connection:
delay(10000); delay(10000);
} }
// start the server: // start the server:
server.begin(); server.begin();
// you're connected now, so print out the status: // you're connected now, so print out the status:

View File

@@ -51,6 +51,9 @@ void setup()
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {

View File

@@ -44,6 +44,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: "); Serial.print("Attempting to connect to SSID: ");

View File

@@ -53,6 +53,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while (status != WL_CONNECTED) { while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: "); Serial.print("Attempting to connect to SSID: ");

View File

@@ -1,15 +1,17 @@
/* /*
Repeating Wifi Web client Repeating Wifi Web Client
This sketch connects to a a web server and makes a request This sketch connects to a a web server and makes a request
using an Arduino Wifi shield. using an Arduino Wifi shield.
Circuit: Circuit:
* Wifi shield attached to pins 10, 11, 12, 13 * WiFi shield attached to pins SPI pins and pin 7
created 23 April 2012 created 23 April 2012
modifide 31 May 2012 modified 31 May 2012
by Tom Igoe by Tom Igoe
modified 13 Jan 2014
by Federico Vanzati
http://arduino.cc/en/Tutorial/WifiWebClientRepeating http://arduino.cc/en/Tutorial/WifiWebClientRepeating
This code is in the public domain. This code is in the public domain.
@@ -32,8 +34,7 @@ char server[] = "www.arduino.cc";
//IPAddress server(64,131,82,241); //IPAddress server(64,131,82,241);
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
boolean lastConnected = false; // state of the connection last time through the main loop const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
const unsigned long postingInterval = 10*1000; // delay between updates, in milliseconds
void setup() { void setup() {
//Initialize serial and wait for port to open: //Initialize serial and wait for port to open:
@@ -49,6 +50,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: "); Serial.print("Attempting to connect to SSID: ");
@@ -72,33 +77,27 @@ void loop() {
Serial.write(c); Serial.write(c);
} }
// if there's no net connection, but there was one last time // if ten seconds have passed since your last connection,
// through the loop, then stop the client: // then connect again and send data:
if (!client.connected() && lastConnected) { if (millis() - lastConnectionTime > postingInterval) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
// if you're not connected, and ten seconds have passed since
// your last connection, then connect again and send data:
if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
httpRequest(); httpRequest();
} }
// store the state of the connection for next time through
// the loop:
lastConnected = client.connected();
} }
// this method makes a HTTP connection to the server: // this method makes a HTTP connection to the server:
void httpRequest() { void httpRequest() {
// close any connection before send a new request.
// This will free the socket on the WiFi shield
client.stop();
// if there's a successful connection: // if there's a successful connection:
if (client.connect(server, 80)) { if (client.connect(server, 80)) {
Serial.println("connecting..."); Serial.println("connecting...");
// send the HTTP PUT request: // send the HTTP PUT request:
client.println("GET /latest.txt HTTP/1.1"); client.println("GET /latest.txt HTTP/1.1");
client.println("Host: www.arduino.cc"); client.println("Host: www.arduino.cc");
client.println("User-Agent: arduino-ethernet"); client.println("User-Agent: ArduinoWiFi/1.1");
client.println("Connection: close"); client.println("Connection: close");
client.println(); client.println();
@@ -108,8 +107,6 @@ void httpRequest() {
else { else {
// if you couldn't make a connection: // if you couldn't make a connection:
Serial.println("connection failed"); Serial.println("connection failed");
Serial.println("disconnecting.");
client.stop();
} }
} }
@@ -132,7 +129,3 @@ void printWifiStatus() {
} }

View File

@@ -44,6 +44,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: "); Serial.print("Attempting to connect to SSID: ");

View File

@@ -61,6 +61,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: "); Serial.print("Attempting to connect to SSID: ");

View File

@@ -66,6 +66,10 @@ void setup() {
while (true); while (true);
} }
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");
// attempt to connect to Wifi network: // attempt to connect to Wifi network:
while ( status != WL_CONNECTED) { while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: "); Serial.print("Attempting to connect to SSID: ");