1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-03 00:29:21 +01:00

Merge remote-tracking branch 'arduino/ide-1.5.x' into ide-1.5.x-discovery

This commit is contained in:
Federico Fissore 2013-05-13 16:58:10 +02:00
commit 2d6af8264b
36 changed files with 171 additions and 139 deletions

View File

@ -31,6 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.jmdns.ServiceEvent; import javax.jmdns.ServiceEvent;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.commons.logging.impl.LogFactoryImpl; import org.apache.commons.logging.impl.LogFactoryImpl;
import org.apache.commons.logging.impl.NoOpLog; import org.apache.commons.logging.impl.NoOpLog;
@ -42,7 +43,6 @@ import processing.app.helpers.FileUtils;
import processing.app.helpers.PreferencesMap; import processing.app.helpers.PreferencesMap;
import processing.app.helpers.filefilters.OnlyDirs; import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.helpers.filefilters.OnlyFilesWithExtension; import processing.app.helpers.filefilters.OnlyFilesWithExtension;
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
import processing.app.packages.Library; import processing.app.packages.Library;
import processing.app.packages.LibraryList; import processing.app.packages.LibraryList;
import processing.app.tools.ZipDeflater; import processing.app.tools.ZipDeflater;
@ -1112,6 +1112,7 @@ public class Base {
} }
}); });
importMenu.add(addLibraryMenuItem); importMenu.add(addLibraryMenuItem);
importMenu.addSeparator();
// Split between user supplied libraries and IDE libraries // Split between user supplied libraries and IDE libraries
TargetPlatform targetPlatform = getTargetPlatform(); TargetPlatform targetPlatform = getTargetPlatform();

View File

@ -131,8 +131,7 @@ public class EditorListener {
// The char is not control code when CTRL key pressed? It should be a shortcut. // The char is not control code when CTRL key pressed? It should be a shortcut.
if (!Character.isISOControl(c)) { if (!Character.isISOControl(c)) {
event.consume(); return false;
return true;
} }
} }

View File

@ -27,6 +27,9 @@ import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import java.awt.datatransfer.*;
import static processing.app.I18n._;
/** /**
* Panel just below the editing area that contains status messages. * Panel just below the editing area that contains status messages.
@ -68,6 +71,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
JButton okButton; JButton okButton;
JTextField editField; JTextField editField;
JProgressBar progressBar; JProgressBar progressBar;
JButton copyErrorButton;
//Thread promptThread; //Thread promptThread;
int response; int response;
@ -109,6 +113,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void notice(String message) { public void notice(String message) {
mode = NOTICE; mode = NOTICE;
this.message = message; this.message = message;
copyErrorButton.setVisible(false);
//update(); //update();
repaint(); repaint();
} }
@ -121,6 +126,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void error(String message) { public void error(String message) {
mode = ERR; mode = ERR;
this.message = message; this.message = message;
copyErrorButton.setVisible(true);
repaint(); repaint();
} }
@ -178,6 +184,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
this.message = message; this.message = message;
progressBar.setIndeterminate(false); progressBar.setIndeterminate(false);
progressBar.setVisible(true); progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint(); repaint();
} }
@ -190,6 +197,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
progressBar.setIndeterminate(true); progressBar.setIndeterminate(true);
progressBar.setValue(50); progressBar.setValue(50);
progressBar.setVisible(true); progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint(); repaint();
} }
@ -208,6 +216,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
if (Preferences.getBoolean("editor.beep.compile")) { if (Preferences.getBoolean("editor.beep.compile")) {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
} }
if (progressBar == null) return;
progressBar.setVisible(false); progressBar.setVisible(false);
progressBar.setValue(0); progressBar.setValue(0);
setCursor(null); setCursor(null);
@ -217,6 +226,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void progressUpdate(int value) public void progressUpdate(int value)
{ {
if (progressBar == null) return;
progressBar.setValue(value); progressBar.setValue(value);
repaint(); repaint();
} }
@ -442,6 +452,32 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
add(progressBar); add(progressBar);
progressBar.setVisible(false); progressBar.setVisible(false);
copyErrorButton = new JButton(
"<html>" + _("Copy error") + "<br>" + _("to clipboard") + "</html>");
Font font = copyErrorButton.getFont();
font = new Font(font.getName(), font.getStyle(), (int) (font.getSize()*0.7));
copyErrorButton.setFont(font);
copyErrorButton.setHorizontalAlignment(JLabel.CENTER);
add(copyErrorButton);
copyErrorButton.setVisible(false);
copyErrorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String message="";
if ((Preferences.getBoolean("build.verbose")) == false) {
message = " " + _("This report would have more information with") + "\n";
message += " \"" + _("Show verbose output during compilation") + "\"\n";
message += " " + _("enabled in File > Preferences.") + "\n";
}
message += _("Arduino: ") + Base.VERSION_NAME + " (" + System.getProperty("os.name") + "), ";
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n";
message += editor.console.consoleTextPane.getText().trim();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection data = new StringSelection(message);
clipboard.setContents(data, null);
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
if (unixclipboard != null) unixclipboard.setContents(data, null);
}
});
} }
} }
@ -474,6 +510,10 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop, editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
editWidth, editHeight); editWidth, editHeight);
progressBar.setBounds(noLeft, editTop, editWidth, editHeight); progressBar.setBounds(noLeft, editTop, editWidth, editHeight);
Dimension copyErrorButtonSize = copyErrorButton.getPreferredSize();
copyErrorButton.setLocation(sizeW - copyErrorButtonSize.width - 5, top);
copyErrorButton.setSize(copyErrorButtonSize.width, Preferences.BUTTON_HEIGHT);
} }

View File

@ -1191,6 +1191,16 @@ public class JEditTextArea extends JComponent
selectionEndLine = newEndLine; selectionEndLine = newEndLine;
biasLeft = newBias; biasLeft = newBias;
if (newStart != newEnd) {
Clipboard unixclipboard = getToolkit().getSystemSelection();
if (unixclipboard != null) {
String selection = getSelectedText();
if (selection != null) {
unixclipboard.setContents(new StringSelection(selection), null);
}
}
}
fireCaretEvent(); fireCaretEvent();
} }
@ -1653,7 +1663,11 @@ public class JEditTextArea extends JComponent
for(int i = 0; i < repeatCount; i++) for(int i = 0; i < repeatCount; i++)
buf.append(selection); buf.append(selection);
clipboard.setContents(new StringSelection(buf.toString()),null); Transferable t = new StringSelection(buf.toString());
clipboard.setContents(t, null);
Clipboard unixclipboard = getToolkit().getSystemSelection();
if (unixclipboard != null) unixclipboard.setContents(t, null);
} }
} }
@ -2210,6 +2224,25 @@ public class JEditTextArea extends JComponent
return; return;
} }
// on Linux, middle button pastes selected text
if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {
Clipboard unixclipboard = getToolkit().getSystemSelection();
if (unixclipboard != null) {
Transferable t = unixclipboard.getContents(null);
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
try {
String s = (String)t.getTransferData(DataFlavor.stringFlavor);
s = s.replace('\u00A0', ' ');
if (editable) setSelectedText(s);
} catch (Exception e) {
System.err.println(e);
e.printStackTrace();
}
}
return;
}
}
int line = yToLine(evt.getY()); int line = yToLine(evt.getY());
int offset = xToOffset(line,evt.getX()); int offset = xToOffset(line,evt.getX());
int dot = getLineStartOffset(line) + offset; int dot = getLineStartOffset(line) + offset;

View File

@ -108,6 +108,8 @@ public class DiscourseFormat {
// i don't care about ownership // i don't care about ownership
} }
}); });
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
if (unixclipboard != null) unixclipboard.setContents(formatted, null);
editor.statusNotice("Code formatted for " + editor.statusNotice("Code formatted for " +
(html ? "HTML" : "the Arduino forum ") + (html ? "HTML" : "the Arduino forum ") +

View File

@ -19,16 +19,18 @@
by David A. Mellis by David A. Mellis
modified 30 Aug 2011 modified 30 Aug 2011
by Limor Fried by Limor Fried
modified 28 Dec 2012
by Mike Walters
This example code is in the public domain. This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Debounce http://www.arduino.cc/en/Tutorial/Debounce
*/ */
// constants won't change. They're used here to // constants won't change. They're used here to
// set pin numbers: // set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin const int ledPin = 13; // the number of the LED pin
// Variables will change: // Variables will change:
int ledState = HIGH; // the current state of the output pin int ledState = HIGH; // the current state of the output pin
@ -43,6 +45,9 @@ long debounceDelay = 50; // the debounce time; increase if the output flicker
void setup() { void setup() {
pinMode(buttonPin, INPUT); pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT); pinMode(ledPin, OUTPUT);
// set initial LED state
digitalWrite(ledPin, ledState);
} }
void loop() { void loop() {
@ -62,11 +67,20 @@ void loop() {
if ((millis() - lastDebounceTime) > debounceDelay) { if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer // whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state: // than the debounce delay, so take it as the actual current state:
buttonState = reading;
// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) {
ledState = !ledState;
}
}
} }
// set the LED using the state of the button: // set the LED:
digitalWrite(ledPin, buttonState); digitalWrite(ledPin, ledState);
// save the reading. Next time through the loop, // save the reading. Next time through the loop,
// it'll be the lastButtonState: // it'll be the lastButtonState:

View File

@ -19,7 +19,7 @@
http://www.arduino.cc/en/Tutorial/KeyboardButton http://www.arduino.cc/en/Tutorial/KeyboardButton
*/ */
const int buttonPin = 2; // input pin for pushbutton const int buttonPin = 4; // input pin for pushbutton
int previousButtonState = HIGH; // for checking the state of a pushButton int previousButtonState = HIGH; // for checking the state of a pushButton
int counter = 0; // button push counter int counter = 0; // button push counter

BIN
build/shared/lib/arduino_icon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

View File

@ -184,6 +184,8 @@ parseInt KEYWORD2
parseFloat KEYWORD2 parseFloat KEYWORD2
readBytes KEYWORD2 readBytes KEYWORD2
readBytesUntil KEYWORD2 readBytesUntil KEYWORD2
readString KEYWORD2
readStringUntil KEYWORD2
# USB-related keywords # USB-related keywords

View File

@ -98,22 +98,32 @@ ARDUINO 1.5 BETA - 2012.10.22
* For more info refer to this press release: * For more info refer to this press release:
http://arduino.cc/blog/2012/10/22/arduino-1-5-support-for-the-due-and-other-processors-easier-library-installation-simplified-board-menu-etc/ http://arduino.cc/blog/2012/10/22/arduino-1-5-support-for-the-due-and-other-processors-easier-library-installation-simplified-board-menu-etc/
ARDUINO 1.0.5 - 2013.03.29 ARDUINO 1.0.5 - 2013.05.15
[core] [core]
* [avr] malloc bug: backported avr-libc 1.8.0 implementation * [avr] malloc bug: backported avr-libc 1.8.0 implementation
* [avr] removed deprecated interrupt handlers causing compiler issues * [avr] removed deprecated interrupt handlers causing compiler issues
with newer avr-gcc. with newer avr-gcc.
* [avr] added c_str() method to String
* [avr] Stream "_timeout" field and related methods are now protected
[libraries] [libraries]
* Upgrades to WiFi library * Upgrades to WiFi library
* Fixed a bunch of examples
[firmwares] [firmwares]
* Upgrades to WiFi firmwares * Upgrades to WiFi firmwares
[ide]
* Backport from 1.5: install Library from .zip file or folder
* Added button "Copy error to clipboard" (Paul Stoffregen)
* Updated windows drivers
* Added Windows installer
ARDUINO 1.0.4 - 2013.03.11 ARDUINO 1.0.4 - 2013.03.11
[core] [core]

Binary file not shown.

View File

@ -1,7 +1,7 @@
; Copyright 2012 Blacklabel Development, Inc. ; Copyright 2012 Blacklabel Development, Inc.
[Strings] [Strings]
DriverPackageDisplayName="Arduino Boards" DriverPackageDisplayName="Arduino USB Driver"
ManufacturerName="Arduino LLC (www.arduino.cc)" ManufacturerName="Arduino LLC (www.arduino.cc)"
ServiceName="USB RS-232 Emulation Driver" ServiceName="USB RS-232 Emulation Driver"
due.bossa.name="Bossa Program Port" due.bossa.name="Bossa Program Port"

BIN
build/windows/dist/drivers/dpinst-amd64.exe vendored Executable file

Binary file not shown.

BIN
build/windows/dist/drivers/dpinst-x86.exe vendored Executable file

Binary file not shown.

View File

@ -48,7 +48,7 @@ void yield(void);
#define EXTERNAL 1 #define EXTERNAL 1
#define INTERNAL 2 #define INTERNAL 2
#else #else
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
#define INTERNAL1V1 2 #define INTERNAL1V1 2
#define INTERNAL2V56 3 #define INTERNAL2V56 3
#else #else

View File

@ -37,7 +37,7 @@ readBytesBetween( pre_string, terminator, buffer, length)
class Stream : public Print class Stream : public Print
{ {
private: protected:
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
unsigned long _startMillis; // used for timeout measurement unsigned long _startMillis; // used for timeout measurement
int timedRead(); // private method to read stream with timeout int timedRead(); // private method to read stream with timeout

View File

@ -45,7 +45,7 @@ int analogRead(uint8_t pin)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers if (pin >= 54) pin -= 54; // allow for channel or pin numbers
#elif defined(__AVR_ATmega32U4__) #elif defined(__AVR_ATmega32U4__)
if (pin >= 18) pin -= 18; // allow for channel or pin numbers if (pin >= 18) pin -= 18; // allow for channel or pin numbers
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
if (pin >= 24) pin -= 24; // allow for channel or pin numbers if (pin >= 24) pin -= 24; // allow for channel or pin numbers
#elif defined(analogPinToChannel) && (defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)) #elif defined(analogPinToChannel) && (defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__))
pin = analogPinToChannel(pin); pin = analogPinToChannel(pin);

View File

@ -54,7 +54,7 @@ extern "C"{
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define EXTERNAL_NUM_INTERRUPTS 8 #define EXTERNAL_NUM_INTERRUPTS 8
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
#define EXTERNAL_NUM_INTERRUPTS 3 #define EXTERNAL_NUM_INTERRUPTS 3
#elif defined(__AVR_ATmega32U4__) #elif defined(__AVR_ATmega32U4__)
#define EXTERNAL_NUM_INTERRUPTS 4 #define EXTERNAL_NUM_INTERRUPTS 4

View File

@ -1,81 +0,0 @@
/*
DNS and DHCP-based Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "www.google.com";
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}

View File

@ -127,6 +127,7 @@ void connectToServer() {
// make HTTP GET request to twitter: // make HTTP GET request to twitter:
client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino&count=1 HTTP/1.1"); client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino&count=1 HTTP/1.1");
client.println("HOST: api.twitter.com"); client.println("HOST: api.twitter.com");
client.println("Connection: close");
client.println(); client.println();
} }
// note the time of this connect attempt: // note the time of this connect attempt:

View File

@ -8,8 +8,9 @@
* Ethernet shield attached to pins 10, 11, 12, 13 * Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009 created 18 Dec 2009
modified 9 Apr 2012
by David A. Mellis by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen
*/ */
@ -18,8 +19,14 @@
// Enter a MAC address for your controller below. // Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield // Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(173,194,33,104); // Google // if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "www.google.com"; // name address for Google (using DNS)
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,0,177);
// Initialize the Ethernet client library // Initialize the Ethernet client library
// with the IP address and port of the server // with the IP address and port of the server
@ -37,8 +44,8 @@ void setup() {
if (Ethernet.begin(mac) == 0) { if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore: // no point in carrying on, so do nothing forevermore:
for(;;) // try to congifure using IP address instead of DHCP:
; Ethernet.begin(mac, ip);
} }
// give the Ethernet shield a second to initialize: // give the Ethernet shield a second to initialize:
delay(1000); delay(1000);
@ -48,7 +55,9 @@ void setup() {
if (client.connect(server, 80)) { if (client.connect(server, 80)) {
Serial.println("connected"); Serial.println("connected");
// Make a HTTP request: // Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0"); client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println(); client.println();
} }
else { else {
@ -73,8 +82,7 @@ void loop()
client.stop(); client.stop();
// do nothing forevermore: // do nothing forevermore:
for(;;) while(true);
;
} }
} }

View File

@ -22,7 +22,7 @@
// The IP address will be dependent on your local network: // The IP address will be dependent on your local network:
byte mac[] = { byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177); IPAddress ip(192,168,1,177);
// Initialize the Ethernet server library // Initialize the Ethernet server library
// with the IP address and port you want to use // with the IP address and port you want to use
@ -63,12 +63,11 @@ void loop() {
// send a standard http response header // send a standard http response header
client.println("HTTP/1.1 200 OK"); client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html"); client.println("Content-Type: text/html");
client.println("Connection: close"); client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println(); client.println();
client.println("<!DOCTYPE HTML>"); client.println("<!DOCTYPE HTML>");
client.println("<html>"); client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin // output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) { for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel); int sensorReading = analogRead(analogChannel);

View File

@ -126,7 +126,7 @@ void sendData(int thisData)
client.print("PUT /v2/feeds/"); client.print("PUT /v2/feeds/");
client.print(FEEDID); client.print(FEEDID);
client.println(".csv HTTP/1.1"); client.println(".csv HTTP/1.1");
client.print("Host: api.pachube.com\n"); client.println("Host: api.pachube.com");
client.print("X-ApiKey: "); client.print("X-ApiKey: ");
client.println(APIKEY); client.println(APIKEY);
client.print("User-Agent: "); client.print("User-Agent: ");
@ -139,7 +139,7 @@ void sendData(int thisData)
client.println(thisLength); client.println(thisLength);
// last pieces of the HTTP PUT request: // last pieces of the HTTP PUT request:
client.print("Content-Type: text/csv\n"); client.println("Content-Type: text/csv");
client.println("Connection: close"); client.println("Connection: close");
client.println(); client.println();

View File

@ -138,7 +138,7 @@ void sendData(String thisData)
client.print("PUT /v2/feeds/"); client.print("PUT /v2/feeds/");
client.print(FEEDID); client.print(FEEDID);
client.println(".csv HTTP/1.1"); client.println(".csv HTTP/1.1");
client.print("Host: api.pachube.com\n"); client.println("Host: api.pachube.com");
client.print("X-ApiKey: "); client.print("X-ApiKey: ");
client.println(APIKEY); client.println(APIKEY);
client.print("User-Agent: "); client.print("User-Agent: ");
@ -147,8 +147,8 @@ void sendData(String thisData)
client.println(thisData.length()); client.println(thisData.length());
// last pieces of the HTTP PUT request // last pieces of the HTTP PUT request
client.print("Content-Type: text/csv\n"); client.println("Content-Type: text/csv");
client.println("Connection: close\n"); client.println("Connection: close");
client.println(); client.println();
// here's the actual content of the PUT request // here's the actual content of the PUT request

View File

@ -2,8 +2,8 @@
Web client Web client
This sketch connects to a website through a GSM shield. Specifically, This sketch connects to a website through a GSM shield. Specifically,
this example downloads the URL "http://arduino.cc/" and prints it this example downloads the URL "http://arduino.cc/asciilogo.txt" and
to the Serial monitor. prints it to the Serial monitor.
Circuit: Circuit:
* GSM shield attached to an Arduino * GSM shield attached to an Arduino
@ -34,7 +34,7 @@ GSM gsmAccess;
// URL, path & port (for example: arduino.cc) // URL, path & port (for example: arduino.cc)
char server[] = "arduino.cc"; char server[] = "arduino.cc";
char path[] = "/"; char path[] = "/asciilogo.txt";
int port = 80; // port 80 is the default for HTTP int port = 80; // port 80 is the default for HTTP
void setup() void setup()
@ -54,7 +54,7 @@ void setup()
while(notConnected) while(notConnected)
{ {
if((gsmAccess.begin(PINNUMBER)==GSM_READY) & if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)) (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
notConnected = false; notConnected = false;
else else
{ {
@ -72,7 +72,10 @@ void setup()
// Make a HTTP request: // Make a HTTP request:
client.print("GET "); client.print("GET ");
client.print(path); client.print(path);
client.println(" HTTP/1.0"); client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println(); client.println();
} }
else else

View File

@ -60,7 +60,7 @@ void loop() {
} }
int digitalPotWrite(int address, int value) { void digitalPotWrite(int address, int value) {
// take the SS pin low to select the chip: // take the SS pin low to select the chip:
digitalWrite(slaveSelectPin,LOW); digitalWrite(slaveSelectPin,LOW);
// send in the address and value via SPI: // send in the address and value via SPI:

View File

@ -132,8 +132,8 @@ void connectToServer() {
Serial.println("making HTTP request..."); Serial.println("making HTTP request...");
// make HTTP GET request to twitter: // make HTTP GET request to twitter:
client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino HTTP/1.1"); client.println("GET /1/statuses/user_timeline.xml?screen_name=arduino HTTP/1.1");
client.println("Host:api.twitter.com"); client.println("Host: api.twitter.com");
client.println("Connection:close"); client.println("Connection: close");
client.println(); client.println();
} }
// note the time of this connect attempt: // note the time of this connect attempt:

View File

@ -31,8 +31,8 @@ int keyIndex = 0; // your network key Index number (needed only for W
int status = WL_IDLE_STATUS; int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size) // if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server: // use the numeric IP instead of the name for the server:
IPAddress server(173,194,73,105); // numeric IP for Google (no DNS) //IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
//char server[] = "www.google.com"; // name address for Google (using DNS) char server[] = "www.google.com"; // name address for Google (using DNS)
// Initialize the Ethernet client library // Initialize the Ethernet client library
// with the IP address and port of the server // with the IP address and port of the server
@ -54,7 +54,7 @@ void setup() {
} }
// 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: ");
Serial.println(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:
@ -72,7 +72,7 @@ void setup() {
Serial.println("connected to server"); Serial.println("connected to server");
// Make a HTTP request: // Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1"); client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host:www.google.com"); client.println("Host: www.google.com");
client.println("Connection: close"); client.println("Connection: close");
client.println(); client.println();
} }

View File

@ -22,7 +22,7 @@
#include <WiFi.h> #include <WiFi.h>
char ssid[] = "yourNetwork"; // your network SSID (name) char ssid[] = "yourNetwork"; // your network SSID (name)
char pass[] = "secretPassword"; // your network password char pass[] = "secretPassword"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP) int keyIndex = 0; // your network key Index number (needed only for WEP)
@ -78,12 +78,11 @@ void loop() {
// send a standard http response header // send a standard http response header
client.println("HTTP/1.1 200 OK"); client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html"); client.println("Content-Type: text/html");
client.println("Connection: close"); client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println(); client.println();
client.println("<!DOCTYPE HTML>"); client.println("<!DOCTYPE HTML>");
client.println("<html>"); client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin // output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) { for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel); int sensorReading = analogRead(analogChannel);
@ -108,9 +107,10 @@ void loop() {
} }
// give the web browser time to receive the data // give the web browser time to receive the data
delay(1); delay(1);
// close the connection:
client.stop(); // close the connection:
Serial.println("client disonnected"); client.stop();
Serial.println("client disonnected");
} }
} }

View File

@ -37,7 +37,7 @@ readBytesBetween( pre_string, terminator, buffer, length)
class Stream : public Print class Stream : public Print
{ {
private: protected:
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
unsigned long _startMillis; // used for timeout measurement unsigned long _startMillis; // used for timeout measurement
int timedRead(); // private method to read stream with timeout int timedRead(); // private method to read stream with timeout

View File

@ -146,6 +146,7 @@ public:
void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
{getBytes((unsigned char *)buf, bufsize, index);} {getBytes((unsigned char *)buf, bufsize, index);}
const char * c_str() const { return buffer; }
// search // search
int indexOf( char ch ) const; int indexOf( char ch ) const;