I'm trying to make a simple GET request to a server (which has a static IP but does not have a name). I'm using EtherCard library and a cheap ENC28J60 Ethernet Module. The basic configurations are OK (I can get DHCP assignment and DNS lookup), but when I try to make a simple GET request with the browseUrl
method, nothing happens. I've tried to call the page from the browser and everything works fine, so it's not a server issue. The code is the following:
#include <EtherCard.h>
// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x54, 0x55, 0x58, 0x10, 0x00, 0x24 };
const char website[] PROGMEM = "http://10.10.10.10"; // my server
const char dnsLook[] PROGMEM = "google.com";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
// called when the client request is complete
static void requestCallback (byte status, word off, word len) {
Serial.print(">>>");
Serial.print(status);
Serial.print("-");
Serial.print(status);
Serial.print("-");
Serial.print(status);
Serial.println("<<<");
}
void setup () {
Serial.begin(9600);
delay (10000);
int res = ether.begin(sizeof Ethernet::buffer, mymac, 8);
if (res == 0)
Serial.println( "Cannot access ethernet interface");
const static uint8_t ip[] = {192,168,1,117};
const static uint8_t gw[] = {192,168,1,1};
const static uint8_t dns[] = {8,8,8,8};
if (!ether.staticSetup(ip, gw, dns))
{
Serial.println("Cannot set static parameters");
}
// manually set netmask
ether.netmask[0] = 255;
ether.netmask[1] = 255;
ether.netmask[2] = 255;
ether.netmask[3] = 0;
// dns lookup
if (!ether.dnsLookup(dnsLook))
Serial.println("DNS failed");
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 10000;
ether.browseUrl(PSTR("/page.php?"), "var=value", website, requestCallback);
}
}