Hello guys,
I'm encountering some problems with my code.
I'm usin' two callbacks function in my sketch but when I pass them as parameters in other functions, it does'nt work because I don't get anything from the Serial port in the two callback functions
Please I need some help
That's my code
#include <NanodeUIP.h>
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
//CALLBACK FUNCTION
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);
}
//CALLBACK FUNCTION
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.print("The mac address is: ");
Serial.println(mac_address);
uip.wait_for_link();
Serial.println("Link is up");
uip.init_resolv(resolv_found);//FUNCTION USIN' THE CALLBACK FUNCTION
uip.start_dhcp(dhcp_status);//FUNCTION USIN' THE CALLBACK FUNCTION
Serial.print("The ip address is: ");
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]
The mac address is: 74:69:69:2D:30:31
Link is up
The ip address is: 0.0.0.0
setup() done