Hi guys,
I am developpin' on an arduino UNO board rev 3 and I have plugged into it a ENC28J60-H ethernet shield.
I'm using the NanodeUIP,NanodeUNIO librairies for my application and I don't know how to get an IP address usin' DHCP. I've also tried the uiptest example but it doesn't work at all.
Maybe I'm just an ignorant newbie in the Arduino World but I definitively don't know how to make it works.
Please I need some help.
Cheers
That's my code
#include <NanodeUIP.h>
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static void resolv_found(char *name, uip_ipaddr_t *addr)
{
Serial.println("fonction resolv_found");
char buf[30]=": addr=";
Serial.print(name);
uip.format_ipaddr(buf+7,addr);
Serial.println(buf);
}
void dhcp_status(int s,const uip_ipaddr_t *dnsaddr)
{
Serial.println("fonction dhcp_status");
char buf[20]="IP:";
if (s==DHCP_STATUS_OK)
{
resolv_conf(dnsaddr);
uip.get_ip_addr_str(buf+3);
Serial.println("l'adresse IP est:");
Serial.println(buf);
uip.query_name("www.greenend.org.uk");
}
}
char mac_address[20];
char ip_address[20];
void setup()
{
Serial.begin(38400);
Serial.println("[UIP test]");
uip.init(mymac);
uip.get_mac_str(mac_address);
Serial.println(mac_address);
uip.wait_for_link();
Serial.println("Link is up");
uip.init_resolv(resolv_found);
uip.start_dhcp(dhcp_status);
uip.get_ip_addr_str(ip_address);
Serial.println(ip_address);
Serial.println("setup() done");
}
void loop()
{
uip.poll();
}
That's what I get from the serial port
[UIP test]
74:69:69:2D:30:31
Link is up
0.0.0.0
setup() done