Hi ikaros, I don't know if you resolved the http request.
During the last week I read a lot about that (enc28j60 and wiznet5xxx).
I'm working with enc28j60 with thiseldo's library.
Check this link: http://blog.thiseldo.co.uk/?tag=enc28j60
the last version: http://blog.thiseldo.co.uk/?p=504
Also I could see a big different about software code when you are preparing a little and clear called request or setup a server. The wiznet library (standard in arduino) is better than enc28j60's libraries.
Anyway I was trying to do a little get request mixing with DHCP feature.
I'm posted the code:
(remember install the last version library)
/* INIT LIBRARY REGION *******************************************************************************/
#include <EtherShield.h>
/* END LIBRARY REGION ********************************************************************************/
/* INIT VARIABLES DECLARATION REGION *****************************************************************/
// count the package received
int packageNumber = 0;
static uint8_t mymac[6] = {
0x54,0x55,0x58,0x10,0x00,0x25};
static uint8_t myip[4] = {
0,0,0,0 };
static uint8_t mynetmask[4] = {
0,0,0,0 };
static uint8_t gwip[4] = {
0,0,0,0};
static uint8_t dnsip[4] = {
0,0,0,0 };
static uint8_t dhcpsvrip[4] = {
0,0,0,0 };
#define BUFFER_SIZE 750
static uint8_t buf[BUFFER_SIZE+1];
EtherShield es = EtherShield();
#define HOSTNAME "arduino.cc"
#define WEBSERVER_VHOST "arduino.cc"
// sub-path http
#define HTTPPATH "/en/Tutorial/StringAppendOperator"
static int8_t dns_state=DNS_STATE_INIT;
/* FINISH VARIABLES DECLARATION REGION ***********************************************************/
/* INIT FUNCTIONS REGION *************************************************************************/
void printNetworkSettings()
{
// Display the results:
Serial.print( "My IP: " );
printIP( myip );
Serial.println();
Serial.print( "Netmask: " );
printIP( mynetmask );
Serial.println();
Serial.print( "DNS IP: " );
printIP( dnsip );
Serial.println();
Serial.print( "GW IP: " );
printIP( gwip );
Serial.println();
}
void printMacAddress()
{
for( int i=0; i<6; i++ ) {
Serial.print( mymac[i], HEX );
Serial.print( i < 5 ? ":" : "" );
}
Serial.println();
}
// Output a ip address from buffer
void printIP( uint8_t *buf ) {
for( int i = 0; i < 4; i++ ) {
Serial.print( buf[i], DEC );
if( i<3 )
Serial.print( "." );
}
}
// Is executed when a package arrives
void browserresult_callback(uint8_t statuscode,uint16_t datapos, uint16_t dataEnd)
{
Serial.println();
Serial.print(packageNumber);
Serial.println(". ------- READING PACKAGE ------------------------------------- ");
Serial.println();
int posInit = 0;
char* text = (char*)&buf[datapos];
while (posInit < dataEnd)
{
Serial.print(text[posInit]);
posInit++;
}
Serial.println();
Serial.println(" ------ FINISH PACKAGE---------------------------------------------- ");
Serial.println();
packageNumber++;
}
/* FINISH FUNCTIONS *******************************************************************************/
void setup() {
Serial.begin(9600);
Serial.println();
Serial.println("DHCP WEB Client test");
Serial.println();
Serial.println("Mac Address:");
printMacAddress();
Serial.println();
// Initialise SPI interface
Serial.println("Init SPI");
es.ES_enc28j60SpiInit();
Serial.println();
// initialize enc28j60
Serial.println("Init ENC28J60");
es.ES_enc28j60Init(mymac);
Serial.println();
Serial.println("Init done");
Serial.println();
Serial.print( "ENC28J60 version " );
Serial.println( es.ES_enc28j60Revision(), HEX);
Serial.println();
if( es.ES_enc28j60Revision() <= 0 ) {
Serial.println( "FAILED TO ACCESS ENC28J60 (check version)");
Serial.println( "The program was canceled.");
while(1); // Just loop here
}
Serial.println("Requesting IP Address");
// Get IP Address details
if( es.allocateIPAddress(buf, BUFFER_SIZE, mymac, 80, myip, mynetmask, gwip, dhcpsvrip, dnsip ) > 0 )
{
Serial.println("Dinamic IP address process successful");
printNetworkSettings();
Serial.println();
}
else {
Serial.println("Failed to get IP address");
Serial.println( "The program was canceled.");
while(1); // Just loop here
}
}
void loop()
{
uint16_t dat_p;
int plen = 0;
// Perform DNS Lookup for host name
if( es.resolveHostname(buf, BUFFER_SIZE,(uint8_t*)WEBSERVER_VHOST ) > 0 ) {
Serial.println("Hostname resolved");
Serial.println();
Serial.println("Processing Get request to:");
Serial.print(HOSTNAME);
Serial.println(HTTPPATH);
Serial.println();
// wait 5 sec. for checking the serial's messages
delay(5000);
es.ES_client_browse_url(PSTR(HTTPPATH), NULL, PSTR(HOSTNAME), &browserresult_callback);
while(1) {
// wait for a tcp packet - calling this routine powers the sending and receiving of data
plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);
dat_p = es.ES_packetloop_icmp_tcp(buf, plen);
}
}
else {
Serial.println("Failed to resolve hostname");
}
}
Good luck with your project ! tell me more about that.