Boa tarde galera, estou fazendo um aplicação ethernet utilizando o chipkit max 32 e o ethernet shield da digilent. Para a minha aplicação estou utilizando o seguinte codigo da biblioteca abaixo, os valores do mac e ip ja foram mudados para eu receber os dados em xml.

byte mac[] = { 0x00, 0x00, 0x0F, 0x06, 0x07, 0x0D };
byte ip[] = { 192,168,25,17 };
byte gateway[] = { 192,168,25,1 };
byte subnet[] = { 255,255,255,192 };
byte dns1[] = {0,0,0,0};
byte dns2[] = {24,113,32,29};

//byte server[] = { 173,194,33,104 }; // Google
//const char * szGoogle = "www.google.com";
const char * szGoogle = "192.168.25.16";
const char * result;
// 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):
Client client(szGoogle, 8080);

void setup() {
// start the Ethernet connection:

// Ethernet.begin(); // DHCP is used, default ENCX24J600 (ENC24J60) MAC address
// Ethernet.begin(mac); // DHCP is used
// Ethernet.begin(mac, ip); // Static IP, gateway equal to the IP with the last byte set to 1 => IP[3].IP[2].IP[1].1
Ethernet.begin(mac, ip, gateway); // default subnet 255.255.255.0
// Ethernet.begin(mac, ip, gateway, subnet); // default dns1 is equal to gateway, some router/gateways act as DNS servers
// Ethernet.begin(mac, ip, gateway, subnet, dns1); // default dns2 is 0.0.0.0
// Ethernet.begin(mac, ip, gateway, subnet, dns1, dns2);

// start the serial library:
// PLEASE NOTE THE SERIAL MODEM SPEED!
// the speed is not the typical 9600; this is because
// the serial monitor can not keep up with the page update
// and will drop characters, the serial monitor must run faster
// When you open the serial monitor, go to the bottom right and select 11500 as the speed
Serial.begin(115200);

// 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()) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /EstufaServer/estufaServer?parametro1=ola HTTP/1.0");
client.println();

// if (client.connected()) {
// if(finder.find("<umidade>")){
// result = finder.getValue();
// Serial.println(result);
//
//}

}
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:
for(;;)
Ethernet.PeriodicTasks();
}
}

O problema é que nao sei como pegar os valores de umidade e temperatura e retira-los da string, tentei usar a biblioteca textfinder.h que tem no playground do site do arduino mais ela não funciona aqui, fala que não foi encontrado nenhum arquivo do arduino.

Pensei em usar a função StringSubstring, e tentar pegar os valores pelo indice, mais não sei como funciona quando muda de linha, e não sei se daria certo trabalhar com \n para pegar os valores.

Alguem ae sabe de alguma maneira que eu poderia usa para pegar os valores. abaixo esta a informação que eu recebo de server

connecting...
connected
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: no-cache
Content-Type: text/xml;charset=ISO-8859-1
Date: Thu, 21 Mar 2013 19:26:41 GMT
Connection: close

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<estufa>
<irrigacao>3.13</irrigacao>
<temperatura>40.1</temperatura>
<umidade>0.0</umidade>
</estufa>

disconnecting.

Obrigado

Exibições: 607

Responder esta

Respostas a este tópico

Estou com mesmo problema. Tentei usar client.read mas nao funcionou.

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço