Hi guys,
I have trouble to get a stable connection with a HanRun HR911105A with a Arduino Nano 3.0
I'm using the Libary "ethercardMaster" (
https://github.com/jcw/ethercard)
My problem:After some (random) time, the connection to the Server is getting unstable - I get no results back. I'am testing yesterday 10 hours to get that fixed, but without success. I also make a very big workarround to automatically restart the board
if the connection is hanging, but this is no solution :-(Sometime it works 1 minute, sometime 2 hours....
Thank you very much for any help! :-)
This is the Code (Democode, called Webclient):
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[700];
static uint32_t timer;
char website[] PROGMEM = "www.softairforum.org";
// 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("\n[webClient]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
ether.printIp("SRV: ", ether.hisip);
}
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);
}
}
Here an example Result:
[webClient]
IP: 192.168.178.38
GW: 192.168.178.1
DNS: 192.168.178.1
SRV: 78.47.199.9
......
<<< REQ >>>
HTTP/1.0 404 Not Found
Connection: close
Content-Type: text/html
Content-Length: 345
Date: Thu, 27 Dec 2012 11:01:01 GMT
Server: lighttpd/1.4.19
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DT...
<<< REQ
<<< REQ
<<< REQ
<<< REQ
<<< REQ