1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-17 22:23:10 +03:00

Run new astyle formatter against all the examples

This commit is contained in:
Federico Fissore
2013-10-21 09:58:40 +02:00
parent 3c6ee46828
commit b4c68b3dff
259 changed files with 5160 additions and 5217 deletions

View File

@ -1,29 +1,29 @@
/*
Cosm sensor client with Strings
This sketch connects an analog sensor to Cosm (http://www.cosm.com)
using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
the Adafruit Ethernet shield, either one will work, as long as it's got
a Wiznet Ethernet module on board.
This example has been updated to use version 2.0 of the Cosm.com API.
This example has been updated to use version 2.0 of the Cosm.com API.
To make it work, create a feed with two datastreams, and give them the IDs
sensor1 and sensor2. Or change the code below to match your feed.
This example uses the String library, which is part of the Arduino core from
version 0019.
version 0019.
Circuit:
* Analog sensor attached to analog in 0
* Ethernet shield attached to pins 10, 11, 12, 13
created 15 March 2010
updated 14 May 2012
by Tom Igoe with input from Usman Haque and Joe Saavedra
http://arduino.cc/en/Tutorial/CosmClientString
This code is in the public domain.
*/
#include <SPI.h>
@ -36,12 +36,13 @@
// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(10,0,1,20);
IPAddress ip(10, 0, 1, 20);
// initialize the library instance:
EthernetClient client;
@ -53,8 +54,8 @@ char server[] = "api.cosm.com"; // name address for Cosm API
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 to Cosm.com
// the "L" is needed to use long type numbers
const unsigned long postingInterval = 10L * 1000L; // delay between updates to Cosm.com
// the "L" is needed to use long type numbers
void setup() {
// start serial port:
Serial.begin(9600);
@ -70,7 +71,7 @@ void setup() {
void loop() {
// read the analog sensor:
int sensorReading = analogRead(A0);
int sensorReading = analogRead(A0);
// convert the data to a String to send it:
String dataString = "sensor1,";
@ -99,8 +100,8 @@ 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)) {
// your last connection, then connect again and send data:
if (!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
sendData(dataString);
}
// store the state of the connection for next time through
@ -132,7 +133,7 @@ void sendData(String thisData) {
// here's the actual content of the PUT request:
client.println(thisData);
}
}
else {
// if you couldn't make a connection:
Serial.println("connection failed");