Hello! I have this problem: in my project i use DHCP-server+ Rabbit MiniCore 6710. Often need switch-off server and Rabbit. If switch-on server and minicore, then server coming up a longer than rabbit and minicore don’t receive ip-address.
Use this code:
#define USE_IF_CALLBACK
#define DTIMEOUT 8 // Define dhcp timeout
static void dhcp_callback(void)
{
auto word dhcp_ok;
ifconfig(IF_DEFAULT,
IFG_DHCP_OK, &dhcp_ok,
IFS_END);
if (dhcp_ok)
{
/*****
init tcp and udp
******/
}
else
{
ifdown(IF_DEFAULT);
return;
}
}
void init()
{
ifconfig(IF_DEFAULT, IFS_ICMP_CONFIG, 1,
IFS_IF_CALLBACK, dhcp_callback,
IFS_DHCP, 1,
IFS_DHCP_FALLBACK, 1,
IFS_IPADDR, inet_addr(“192.168.2.13”),
IFS_NETMASK, inet_addr(“255.255.255.0”),
IFS_END);
sock_init();
while (ifpending(IF_DEFAULT) == IF_COMING_UP)
{
WDT_Reset();
tcp_tick(NULL);
}
}
After this code checking connection - and if minicore don’t receive any message, then init() called again. And problem in this - DHCP-server already work fine, but rabbit don’t receive address.