mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-07 00:04:36 +03:00
Run new astyle formatter against all the examples
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
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
|
||||
|
||||
|
||||
created 23 April 2012
|
||||
modifide 31 May 2012
|
||||
by Tom Igoe
|
||||
|
||||
|
||||
http://arduino.cc/en/Tutorial/WifiWebClientRepeating
|
||||
This code is in the public domain.
|
||||
*/
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <SPI.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
char ssid[] = "yourNetwork"; // your network SSID (name)
|
||||
char ssid[] = "yourNetwork"; // your network SSID (name)
|
||||
char pass[] = "secretPassword"; // your network password
|
||||
int keyIndex = 0; // your network key Index number (needed only for WEP)
|
||||
|
||||
@@ -33,36 +33,36 @@ char server[] = "www.arduino.cc";
|
||||
|
||||
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 = 10 * 1000; // delay between updates, in milliseconds
|
||||
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
|
||||
// check for the presence of the shield:
|
||||
if (WiFi.status() == WL_NO_SHIELD) {
|
||||
Serial.println("WiFi shield not present");
|
||||
Serial.println("WiFi shield not present");
|
||||
// don't continue:
|
||||
while(true);
|
||||
}
|
||||
while (true);
|
||||
}
|
||||
|
||||
String fv = WiFi.firmwareVersion();
|
||||
if( fv != "1.1.0" )
|
||||
if ( fv != "1.1.0" )
|
||||
Serial.println("Please upgrade the firmware");
|
||||
|
||||
|
||||
// attempt to connect to Wifi network:
|
||||
while ( status != WL_CONNECTED) {
|
||||
while ( status != WL_CONNECTED) {
|
||||
Serial.print("Attempting to connect to SSID: ");
|
||||
Serial.println(ssid);
|
||||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
|
||||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
|
||||
status = WiFi.begin(ssid, pass);
|
||||
|
||||
// wait 10 seconds for connection:
|
||||
delay(10000);
|
||||
}
|
||||
}
|
||||
// you're connected now, so print out the status:
|
||||
printWifiStatus();
|
||||
}
|
||||
@@ -86,7 +86,7 @@ void loop() {
|
||||
|
||||
// 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 (!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
|
||||
httpRequest();
|
||||
}
|
||||
// store the state of the connection for next time through
|
||||
@@ -108,7 +108,7 @@ void httpRequest() {
|
||||
|
||||
// note the time that the connection was made:
|
||||
lastConnectionTime = millis();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// if you couldn't make a connection:
|
||||
Serial.println("connection failed");
|
||||
|
Reference in New Issue
Block a user