Pages: [1] 2   Go Down
Author Topic: getting a - expected unqualified id before"{" token..  (Read 758 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

getting a - expected unqualified id before"{" token..

any ideas

Code:
EthernetClient client;
EthernetServer server(80);

void setup()
{
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
}

{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  //lcd.print("W-");
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2921
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Full code?
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 505
Posts: 31332
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
getting a - expected unqualified id before"{" token..

Where?

It normally means you have missed out a semicolon on the line before.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

line 73... cheers

Code:
////
//
// General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2
//
////

#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN A1     // what pin we're connected to
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

/////////////////
// MODIFY HERE //
/////////////////
byte mac[] = {
  0x00, 0x13, 0x02, 0xCC, 0xD1, 0x19 };   // Be sure this address is unique in your network
byte ip[] = { 192,168,0, 101 };

//Your secret DevID from PushingBox.com. You can use multiple DevID  on multiple Pin if you want
char DEVID1[] = "v1CC65E36Dxxxx00";        //Scenario : 1
char DEVID2[] = "v9565F5FAAxxxx41";        //Scenario : 2


//Numeric Pin where you connect your switch
#define pinDevid1 8// mm
#define pinDevid2 9// mm

///               4    6  11  12 13  14
//                rs, en, D4, D5 D6  D7
LiquidCrystal lcd(A4, A5 , 3, 2, A3, A2);

int sensorPin = A0; // select the input pin for the  detector
//int countMAILW=0;
int count = 0;
int FED = 0;
int countMAILF = 0;

int sensorValue = 0;  // variable to store the value coming from the  detector
byte latch = 0;  //initial variable
const int pump = 4;
const int fan = 5;


// Debug mode
#define DEBUG true
//////////////
//   End    //
//////////////


char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false;
boolean pinDevid2State = false;
boolean lastConnected = false;                 // state of the connection last time through the main loop


// 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;
EthernetServer server(80);

void setup()
{
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
}

{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  //lcd.print("W-");


  Serial.begin(9600);
  pinMode(pinDevid1, OUTPUT);// pin 8
  //pinMode(pinDevid2, INPUT);// pin 9
  pinMode(fan, OUTPUT);//
  pinMode(pump, OUTPUT);//
 // pinMode(relay, OUTPUT);
  dht.begin();


  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");

    lcd.setCursor(0,0);
    lcd.print("Disconnected ");


    //while(true);// no point in carrying on, so do nothing forevermore:

  }
  else{

    Serial.println("Ethernet ready");

    lcd.setCursor(0,0);
    lcd.print("Net OK ");
    delay(2000);
    lcd.clear();

    Serial.print("My IP address: ");// print the Ethernet board/shield's IP address:
    Serial.println(Ethernet.localIP());
    lcd.print(Ethernet.localIP());
    delay(2000);
    lcd.clear();
    FED=0;
    lcd.setCursor(10,0);
    lcd.print("F");
    lcd.print(FED);
    


  }

  delay(500);// give the Ethernet shield a second to initialize:
}}

void loop()
Client client = server.available();
if (client) {

// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();

// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 1; analogChannel++) {
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(analogRead(analogChannel));
client.println("<br />");

}

break;

}

if (c == '\n') {

// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {

// you've gotten a character on the current line
currentLineIsBlank = false;

}

}

}

// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();

}

}
{
  
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  }
  else {
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print("  %   ");
    Serial.print("Temp: ");
    Serial.print(t);
    Serial.println("C");
  }


  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(8, 1);
  lcd.print("H:");
  lcd.print(h);
  lcd.print("%");
  //delay(2000);
  lcd.setCursor(0, 1);
  lcd.print("T:");
  lcd.print(t);
  //lcd.print("C");
  //delay(2000);

  
    if(t>=26)
    
   { digitalWrite(fan, HIGH);
    lcd.setCursor(15, 0);
  lcd.print("F");}
  
   if(t<=24)
    
   { digitalWrite(fan, LOW);
  lcd.setCursor(15, 0);
  lcd.print("_");}
 
  

lcd.setCursor(0,0);
lcd.print("W-");
  lcd.setCursor(2,0);// (note: line 1 is the second row, since counting begins with 0):
  // print the number of seconds since reset:
  lcd.print(sensorValue);

  sensorValue = analogRead(sensorPin); // read the value from the soil detector:

  Serial.print("moisture sensor reads ");
  Serial.println( sensorValue );  
  delay(100);

  if(sensorValue<750 && count==0)
  {
    //countMAILF=0;
    delay(2000);
    if(sensorValue<750 && count==0)
    delay(2000);
    digitalWrite(pinDevid1, HIGH);
    digitalWrite(pump, LOW);
    lcd.setCursor(14, 0);
  lcd.print("P");
  delay(10000);
  digitalWrite(pump, HIGH);
  lcd.setCursor(14, 0);
  lcd.print("R");
  //digitalWrite(pinDevid1, HIGH);
  }
count++;// this increments the count by 1
  
 
  


 


  if(sensorValue>800)
  //if(countMAILF ==0)
 {digitalWrite(pinDevid1, LOW);
  digitalWrite(pump, LOW);
 lcd.setCursor(14, 0);
  lcd.print("_");
 count=0;}



  if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false )// switch on pinDevid1 is ON
  {

    if(DEBUG){
      Serial.println("pinDevid1 is HIGH");
    }
    pinDevid1State = true;


    sendToPushingBox(DEVID1);//Sending request to PushingBox when the pin is HIGHT
    delay(500);


  }
  delay(1000);


  if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
  {
    if(DEBUG){
      Serial.println("pinDevid1 is LOW");
    }
    pinDevid1State = false;
    sendToPushingBox(DEVID2);
    
   // digitalWrite(9, HIGH);
  }
    //digitalWrite(pump, LOW);
    delay(500);
    
   // countMAILF = val;
  


  //DEBUG part
  // this write the respons from PushingBox Server.
  // You should see a "200 OK"
  if (client.available()) {
    char c = client.read();
    if(DEBUG){
      Serial.print(c);
    }
  }

  // if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected() && lastConnected) {
    if(DEBUG){
      Serial.println();
    }
    if(DEBUG){
      Serial.println("disconnecting.");
    }
    client.stop();
  }
  lastConnected = client.connected();
}


//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){
    Serial.println("connecting...");
    lcd.setCursor(0,0);
    lcd.print("connecting.... ");
    delay(1000);
  }

  if (client.connect(serverName, 80)) {
    if(DEBUG){
      Serial.println("connected    ");
      lcd.setCursor(0,0);
      lcd.print("connected     ");
      delay(1000);
    }

    if(DEBUG){
      Serial.println("sendind request");
    }
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
    lcd.setCursor(0,0);
    lcd.print(" sent!       ");
    delay(5000);
    lcd.clear();
    
  }

  else {
    if(DEBUG){
      Serial.println("connection failed");
    }
  }}}

« Last Edit: February 15, 2013, 03:02:58 pm by Hackdub » Logged

California
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3123
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Auto Format Failed: Too many right curly braces

If you format your code in a more conventional way, this shouldn't be difficult to spot.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 547
Posts: 45950
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The correct ratio of answers to questions is a minimum of 1:1. You ratio is a bit less than that.
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2921
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The lack of proper formatting this code has, will haunt me in my dreams.

No function?
Code:
{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  //lcd.print("W-");


  Serial.begin(9600);
  pinMode(pinDevid1, OUTPUT);// pin 8
  //pinMode(pinDevid2, INPUT);// pin 9
  pinMode(fan, OUTPUT);//
  pinMode(pump, OUTPUT);//
 // pinMode(relay, OUTPUT);
  dht.begin();


  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");

    lcd.setCursor(0,0);
    lcd.print("Disconnected ");


    //while(true);// no point in carrying on, so do nothing forevermore:

  }
  else{

    Serial.println("Ethernet ready");

    lcd.setCursor(0,0);
    lcd.print("Net OK ");
    delay(2000);
    lcd.clear();

    Serial.print("My IP address: ");// print the Ethernet board/shield's IP address:
    Serial.println(Ethernet.localIP());
    lcd.print(Ethernet.localIP());
    delay(2000);
    lcd.clear();
    FED=0;
    lcd.setCursor(10,0);
    lcd.print("F");
    lcd.print(FED);
   


  }
« Last Edit: February 15, 2013, 03:06:51 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3448
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is this the full extent of the setup() function ?
Code:
void setup()
{
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
}
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK lets start again.. I want to display some analogue values on a server, as well as using pushing box.

so I want to combine this code
Code:
// for W5100 ethernet shield
// the IP address will be dependent on your local network/router
// port 80 is default for HTTP, but can be changed as needed
// use IP address like http://192.168.1.102/ in your brouser

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
Server server(80);

void setup()
{
  // start the server
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
     while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // see if HTTP request has ended with blank line
        if (c == '\n') {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          //meta-refresh page every 2 seconds
          client.print("<HEAD>");
          client.print("<meta http-equiv=\"refresh\" content=\"2\">");
          client.print("<TITLE />Zoomkat's meta-refresh test</title>");
          client.print("</head>");
                    
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");
            }
          break;
           }
        }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

and wanted to combine with my code  with my code

Code:
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN A1     // what pin we're connected to
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

/////////////////
// MODIFY HERE //
/////////////////
byte mac[] = {
  0x00, 0x13, 0x02, 0xCC, 0xD1, 0x19 };   // Be sure this address is unique in your network

//Your secret DevID from PushingBox.com. You can use multiple DevID  on multiple Pin if you want
char DEVID1[] = "v1CC65E36Dxxx00";        //Scenario
char DEVID2[] = "v9565F5FAAxxx41";        //Scenario


//Numeric Pin where you connect your switch
#define pinDevid1 8// Water
#define pinDevid2 9// FED

///               4    6  11  12 13  14
//                rs, en, D4, D5 D6  D7
LiquidCrystal lcd(A4, A5 , 3, 2, A3, A2);

int sensorPin = A0; // select the input pin for the detector
//int countMAILW=0;
int count = 0;
int FED = 0;
int countMAILF = 0;

int sensorValue = 0;  // variable to store the value coming from the detector
byte latch = 0;  //initial variable
const int pump = 4;
const int fan = 5;


// Debug mode
#define DEBUG true
//////////////
//   End    //
//////////////


char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false;
boolean pinDevid2State = false;
boolean lastConnected = false;                 // state of the connection last time through the main loop


// 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() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  //lcd.print("W-");


  Serial.begin(9600);
  pinMode(pinDevid1, OUTPUT);// pin 8
  //pinMode(pinDevid2, INPUT);// pin 9
  pinMode(fan, OUTPUT);//
  pinMode(pump, OUTPUT);//
  // pinMode(relay, OUTPUT);
  dht.begin();


  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");

    lcd.setCursor(0,0);
    lcd.print("Disconnected ");


    //while(true);// no point in carrying on, so do nothing forevermore:

  }
  else{

    Serial.println("Ethernet ready");

    lcd.setCursor(0,0);
    lcd.print("Net OK ");
    delay(2000);
    lcd.clear();

    Serial.print("My IP address: ");// print the Ethernet board/shield's IP address:
    Serial.println(Ethernet.localIP());
    lcd.print(Ethernet.localIP());
    delay(2000);
    lcd.clear();
    FED=0;
    lcd.setCursor(10,0);
    lcd.print("F");
    lcd.print(FED);



  }

  delay(500);// give the Ethernet shield a second to initialize:
}

void loop()
{

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  }
  else {
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print("  %   ");
    Serial.print("Temp: ");
    Serial.print(t);
    Serial.println("C");
  }


  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(8, 1);
  lcd.print("H:");
  lcd.print(h);
  lcd.print("%");
  //delay(2000);
  lcd.setCursor(0, 1);
  lcd.print("T:");
  lcd.print(t);
  //lcd.print("C");
  //delay(2000);


  if(t>=26)

  {
    digitalWrite(fan, HIGH);
    lcd.setCursor(15, 0);
    lcd.print("F");
  }

  if(t<=24)

  {
    digitalWrite(fan, LOW);
    lcd.setCursor(15, 0);
    lcd.print("_");
  }



  lcd.setCursor(0,0);
  lcd.print("W-");
  lcd.setCursor(2,0);// (note: line 1 is the second row, since counting begins with 0):
  // print the number of seconds since reset:
  lcd.print(sensorValue);

  sensorValue = analogRead(sensorPin); // read the value from the soil detector:

  Serial.print("moisture sensor reads ");
  Serial.println( sensorValue );  
  delay(100);

  if(sensorValue<750 && count==0)
  {
    //countMAILF=0;
    delay(2000);
    if(sensorValue<750 && count==0)
      delay(2000);
    digitalWrite(pinDevid1, HIGH);
    digitalWrite(pump, LOW);
    lcd.setCursor(14, 0);
    lcd.print("P");
    delay(10000);
    digitalWrite(pump, HIGH);
    lcd.setCursor(14, 0);
    lcd.print("R");
    //digitalWrite(pinDevid1, HIGH);
  }
  count++;// this increments the count by 1








  if(sensorValue>800)
    //if(countMAILF ==0)
  {
    digitalWrite(pinDevid1, LOW);
    digitalWrite(pump, LOW);
    lcd.setCursor(14, 0);
    lcd.print("_");
    count=0;
  }



  if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false )// switch on pinDevid1 is ON
  {

    if(DEBUG){
      Serial.println("pinDevid1 is HIGH");
    }
    pinDevid1State = true;


    sendToPushingBox(DEVID1);//Sending request to PushingBox when the pin is HIGHT
    delay(500);


  }
  delay(1000);


  if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
  {
    if(DEBUG){
      Serial.println("pinDevid1 is LOW");
    }
    pinDevid1State = false;
    sendToPushingBox(DEVID2);

    // digitalWrite(9, HIGH);
  }
  //digitalWrite(pump, LOW);
  delay(500);

  // countMAILF = val;



  //DEBUG part
  // this write the respons from PushingBox Server.
  // You should see a "200 OK"
  if (client.available()) {
    char c = client.read();
    if(DEBUG){
      Serial.print(c);
    }
  }

  // if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected() && lastConnected) {
    if(DEBUG){
      Serial.println();
    }
    if(DEBUG){
      Serial.println("disconnecting.");
    }
    client.stop();
  }
  lastConnected = client.connected();
}


//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){
    Serial.println("connecting...");
    lcd.setCursor(0,0);
    lcd.print("connecting.... ");
    delay(1000);
  }

  if (client.connect(serverName, 80)) {
    if(DEBUG){
      Serial.println("connected    ");
      lcd.setCursor(0,0);
      lcd.print("connected     ");
      delay(1000);
    }

    if(DEBUG){
      Serial.println("sendind request");
    }
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
    lcd.setCursor(0,0);
    lcd.print(" sent!       ");
    delay(5000);
    lcd.clear();

  }

  else {
    if(DEBUG){
      Serial.println("connection failed");
    }
  }
}



Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry three replies due to charcter count..

the initial  server code came from ..http://arduino.cc/forum/index.php?topic=70177.0;wap2

but creates these errors











sketch_feb15a:11: error: no matching function for call to 'Server::Server(int)'

As of Arduino 1.0, the Server class in the Ethernet library has been renamed to EthernetServer.

C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:4: note: candidates are: Server::Server()
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:4: note:                 Server::Server(const Server&)
sketch_feb15a:11: error: cannot declare variable 'server' to be of abstract type 'Server'
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:4: note:   because the following virtual functions are pure within 'Server':
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Print.h:48: note:    virtual size_t Print::write(uint8_t)
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:6: note:    virtual void Server::begin()
sketch_feb15a.ino: In function 'void loop()':
sketch_feb15a:23: error: 'class Server' has no member named 'available'
sketch_feb15a:23: error: cannot declare variable 'client' to be of abstract type 'Client'
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:7: note:   because the following virtual functions are pure within 'Client':
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:12: note:    virtual size_t Client::write(uint8_t)
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:13: note:    virtual size_t Client::write(const uint8_t*, size_t)
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:14: note:    virtual int Client::available()
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:15: note:    virtual int Client::read()
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:17: note:    virtual int Client::peek()
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:18: note:    virtual void Client::flush()
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:10: note:    virtual int Client::connect(IPAddress, uint16_t)
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:11: note:    virtual int Client::connect(const char*, uint16_t)
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:16: note:    virtual int Client::read(uint8_t*, size_t)
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:19: note:    virtual void Client::stop()
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:20: note:    virtual uint8_t Client::connected()
C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:21: note:    virtual Client::operator bool()

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 505
Posts: 31332
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Close but no coconut.
You gave two sketches and the error from when you tried to combine the two but you did not give the combined code that gave those error messages.

For what you need to do to combine two sketches see here:-
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok cheers mike...

Im getting errors on just the client... before i merge it.. it looks like its not compatible with my library.
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2921
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it looks like its not compatible with my library.
Or you didn't put the library in the correct folder. What IDE are you using?
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Full Member
***
Karma: 0
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1.03  ver

OK made a lot of progess.. found a working client in examples... DOH  ...
Code:
/*
  Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 
 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,7);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

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 and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();
          client.println("<!DOCTYPE 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
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");      
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

Just struggling to get it to merge with my original code.....  the loop part... just cant find the right place to drop it in.

cheers

David
« Last Edit: February 15, 2013, 05:00:16 pm by Hackdub » Logged

Pages: [1] 2   Go Up
Jump to: