Pessoal, Bom dia.

Estou quebrando a cabeça com varias bibliotecas para enc28j60, porém não consigo fazer o bendito executar uma url que contem o código php para alterar um status no banco, esse código é um simples uptade do sql que quando acessado pelo endereço http://192.168.14.10/arduino/portas.php, alterar o status da porta para aberta ou fechada, toda a logica esta na própria pagina, é simples e rápida a execução.

Porém o código que estou usando não executa a url, eu consigo pegar ip e me comunicar na rede, porém não executa a url, vejam o código do arduino:

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = {0x00,0x19,0xCB,0xF4,0x03,0x01};
static byte myip[] = {192,168,14,209};
static byte gwip[] = {192,168,14,3};
static byte netmask[] = {255,255,255,0};
static byte dnsip[] = {192,168,0,22};
byte Ethernet::buffer[700];

static uint32_t timer;

const char website[] PROGMEM = "http://192.168.14/arduino/portas.php";

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
Serial.println(">>>");
Ethernet::buffer[off+300] = 0;
Serial.print((const char*) Ethernet::buffer + off);
Serial.println("...");
}

void setup () {
Serial.begin(57600);
Serial.println(F("\n[webClient]"));

if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
Serial.println( "Accesso fallito all'Ethernet Shield");
else
Serial.println("Ethernet Shield initializzato");

if (!ether.staticSetup(myip, gwip, dnsip, netmask ))
Serial.println("Impossibile assegnare l'indirizzo");
else
Serial.println("Indirizo statico configurato");

ether.printIp("IP Address:\t", ether.myip);
ether.printIp("Netmask:\t", ether.netmask);
ether.printIp("Gateway:\t", ether.gwip);
ether.printIp("DNS:\t\t", ether.dnsip);
Serial.println();

}

void loop () {
ether.packetLoop(ether.packetReceive());

if (millis() > timer) {
timer = millis() + 5000;
Serial.println();
Serial.print("< REQ ");
ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);
}
}

Alguém pode me ajudar.

Exibições: 987

Responder esta

Respostas a este tópico

Renato, o endereço IP está incompleto?

const char website[] PROGMEM = "http://192.168.14/arduino/portas.php";

Parece que sim

(...) esse código é um simples uptade do sql que quando acessado pelo endereço http://192.168.14.10/arduino/portas.php, (...)

 

Pessoal, isso eu já havia corrigido.

Segue o site que salvou:

http://ivairt.blogspot.com.br/2013/10/web-cliente-com-arduino-e-enc...

Nesse projeto eu uso um Reed Switch para identificar portas abertas/fechadas.

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço