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:
@@ -12,6 +12,7 @@
|
||||
modified 31 May 2012
|
||||
by Tom Igoe
|
||||
*/
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // the name of your network
|
||||
@@ -31,6 +32,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to open SSID: ");
|
||||
|
@@ -22,6 +22,7 @@
|
||||
modified 31 May 2012
|
||||
by Tom Igoe
|
||||
*/
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // your network SSID (name)
|
||||
@@ -43,6 +44,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to WEP network, SSID: ");
|
||||
|
@@ -12,6 +12,7 @@
|
||||
modified 31 May 2012
|
||||
by Tom Igoe
|
||||
*/
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // your network SSID (name)
|
||||
@@ -32,6 +33,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to WPA SSID: ");
|
||||
|
@@ -32,6 +32,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// Print WiFi MAC address:
|
||||
printMacAddress();
|
||||
|
||||
|
@@ -40,6 +40,10 @@ void setup() {
|
||||
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:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to Network named: ");
|
||||
|
@@ -47,6 +47,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
@@ -57,6 +61,7 @@ void setup() {
|
||||
// wait 10 seconds for connection:
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
// start the server:
|
||||
server.begin();
|
||||
// you're connected now, so print out the status:
|
||||
|
@@ -51,6 +51,9 @@ void setup()
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
|
@@ -44,6 +44,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
|
@@ -53,6 +53,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while (status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
|
@@ -1,15 +1,17 @@
|
||||
/*
|
||||
Repeating Wifi Web client
|
||||
Repeating Wifi Web Client
|
||||
|
||||
This sketch connects to a a web server and makes a request
|
||||
using an Arduino Wifi shield.
|
||||
|
||||
Circuit:
|
||||
* Wifi shield attached to pins 10, 11, 12, 13
|
||||
* WiFi shield attached to pins SPI pins and pin 7
|
||||
|
||||
created 23 April 2012
|
||||
modifide 31 May 2012
|
||||
modified 31 May 2012
|
||||
by Tom Igoe
|
||||
modified 13 Jan 2014
|
||||
by Federico Vanzati
|
||||
|
||||
http://arduino.cc/en/Tutorial/WifiWebClientRepeating
|
||||
This code is in the public domain.
|
||||
@@ -32,8 +34,7 @@ char server[] = "www.arduino.cc";
|
||||
//IPAddress server(64,131,82,241);
|
||||
|
||||
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 = 10*1000; // delay between updates, in milliseconds
|
||||
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
|
||||
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
@@ -49,6 +50,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
@@ -72,33 +77,27 @@ void loop() {
|
||||
Serial.write(c);
|
||||
}
|
||||
|
||||
// if there's no net connection, but there was one last time
|
||||
// through the loop, then stop the client:
|
||||
if (!client.connected() && lastConnected) {
|
||||
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)) {
|
||||
// if ten seconds have passed since your last connection,
|
||||
// then connect again and send data:
|
||||
if (millis() - lastConnectionTime > postingInterval) {
|
||||
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:
|
||||
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 (client.connect(server, 80)) {
|
||||
Serial.println("connecting...");
|
||||
// send the HTTP PUT request:
|
||||
client.println("GET /latest.txt HTTP/1.1");
|
||||
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();
|
||||
|
||||
@@ -108,8 +107,6 @@ void httpRequest() {
|
||||
else {
|
||||
// if you couldn't make a connection:
|
||||
Serial.println("connection failed");
|
||||
Serial.println("disconnecting.");
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +129,3 @@ void printWifiStatus() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -44,6 +44,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
|
@@ -61,6 +61,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
|
@@ -66,6 +66,10 @@ void setup() {
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
|
Reference in New Issue
Block a user